I’m trying to generate the id of a td element, based on it’s row number.
I believe that the td id must be unique. Maybe I am wrong?
I’m therefore trying to concatenate the row number with some text but can’t seem to get it to work.
We are using jQuery on our website and I can successfully create other id’s which are based on variables, but i’m a little stuck on this one. Here’s an example of something that works
<td id="person-id${person.id}">${person.name}</td>
The html will later look something like:
<td id="person1"></td><td id="person2"></td><td id="person3"></td> etc
I was hoping to do something like this for another table but having some trouble:
<td id="row-number("+rowIndex+")">some text here</td>
Any help would be appreciated.
I’m assuming you want to assign the id based on column number, not row number. If I’m correct in this assumption, you can do it with jQuery like so:
Otherwise, if you do want the row number assigned to the id, it would be:
Voila.