mouseover a tables cell.

H

hari

I want to retreive the row number of a cell in the table when the
mouse is over that cell.
Can any one help?
 
M

Michael Winter

I want to retreive the row number of a cell in the table when the
mouse is over that cell.
Can any one help?

With modern, DOM-supporting browsers, you can obtain the parent of the
table (the row), and get the row index of that via a property.

<tr>
<td onmouseover="getRowIndex(this);">
...


function getRowIndex(cell) {
var row = cell.parentNode;
if(row && 'undefined' != typeof row.rowIndex) {
return row.rowIndex; // or row.sectionRowIndex
}
}

The difference between rowIndex and sectionRowIndex is that the former
runs throughout the entire table. The latter restarts at the beginning of
each table section (TBODY, THEAD and TFOOT). Indicies are zero-order.

Hope that helps,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top