I have a page that is creating dynamically created rows in a table with an input with an ID “fixedRate”
I am trying to rename each instance of the fixedRate id. This is only working for the first instance of the id with my current code.
Here is the code:
var amountRows = $("#billTasks > tr").size();
var i=1;
$("#fixedRate").each(function(){
if (i == amountRows) {
return false;
}
this.id = this.id + i;
i++;
});
The way I think the code should work is adding a 1,2,3,… at the end of the word fixedRate for each instance of the fixedRate ID. (i.e. fixedRate1, fixedRate2,…)
Do I need to use a while loop? I have tried many different things including a while loop and have managed to crash my browser over and over. So now I am looking for your help!
thanks!!!
Identifiers are mainly for singling out elements, if you want a wide group.
I suggest you convert the id into a class such as
Then you can access all elements by using the selector
also if you want to enumerate all the elements you can use the each function with two parameters in the callback