I’d like to be able to assign each row in a table an Id so I can easily find the row(s) later using JavaScript. I see where I can set the id of the table but I’d like to also assign an id to each row with a unique value that will make the row I want easy to find.
Answer
<apex:page standardController="Account">
<apex:variable value="{!1}" var="rowNum"/>
<table>
<apex:repeat value="{!Account.contacts}" var="item">
<tr id="hello{!rowNum}"><td>{!item.Name}</td></tr>
<apex:variable var="rowNum" value="{!rowNum + 1}"/>
</apex:repeat>
</table>
</apex:page>
Another solution using apex variable
Attribution
Source : Link , Question Author : Robert Harper , Answer Author : Mohith Shrivastava