Input fields occur dynamically by what the user needs in my script.
For example:
<div class='row'><input class='number' type='text' /><<input class='total' type='text' /></div>
<div class='row'><input class='number' type='text' /><<input class='total' type='text' /></div>
<div class='row'><input class='number' type='text' /><<input class='total' type='text' /></div>
I want to know on keyup which input field is changed and do something with the inputted value. My idea is to do that by the class index.
I tried to get the class index by the following script:
$(document).ready(function(){
$(".number").keydown(function(){
alert($(this).index());
});
});
But which field I test, he shows index 0 instead of index 1 or two if I type something in an other input field. What am I doing wrong?