I have a link ( anchor ) tag in a table cell on every row of an html table. On click of this anchor tag I want to use jquery ( preferably) to traverse back to the parent td and tr and get object reference to it.
how can i use jquery at best here to navigate\traverse in dom.
I can do a method like this but not sure if jquery has better ways for this.
function findRowNumber(element)
{
// element is a descendent of a tr element
while(element.tagName.toLowerCase() != "tr")
{
element = element.parentNode; // breaks if no "tr" in path to root
}
return element.rowIndex;
}