I have a set of inputs as:
<input type="text" id="Class3Row0" name="Class3" class="Row0" value="0" onkeypress="return isNumberKey(event)">
<input type="text" id="Class3Row1" name="Class3" class="Row1" value="0" onkeypress="return isNumberKey(event)">
<input type="text" id="Class3Row2" name="Class3" class="Row0" value="0" onkeypress="return isNumberKey(event)">
.......
So as it can be seen, each id
forms the pattern "Class3RowNo"
.
When I execute the jQuery:
$(function(){
$('input[id^="Class3"]').on('mouseover',function(){
alert("invoked!!");
});
});
The mouse when over the first input
above(i.e. the one with id="Class3Row0"
) the alert appears.But for other input
elements, it does not although their id
starts with "Class3"
.So whats wrong here and how should I get things done?
EDIT:
It seems worth mentioning here that the inputs after the first input
element are added dynamically following the simple algorithm:
- Cloning the first input with class changed to Row1,Row2,Row3....
- resetting their id field to their name+class