mouseover a tables cell.

Discussion in 'Javascript' started by hari, Oct 8, 2004.

  1. hari

    hari Guest

    I want to retreive the row number of a cell in the table when the
    mouse is over that cell.
    Can any one help?
    hari, Oct 8, 2004
    #1
    1. Advertising

  2. On 8 Oct 2004 13:05:46 -0700, hari <> wrote:

    > 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

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
    Michael Winter, Oct 9, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Walzenbach
    Replies:
    1
    Views:
    820
    Steven Cheng[MSFT]
    Feb 18, 2004
  2. Peter Bassett
    Replies:
    3
    Views:
    912
    Augustus
    Aug 15, 2003
  3. Otuatail

    Tables within tables

    Otuatail, Jul 31, 2004, in forum: HTML
    Replies:
    7
    Views:
    482
  4. Chris Brat
    Replies:
    5
    Views:
    687
    =?iso-8859-1?q?Luis_M._Gonz=E1lez?=
    Aug 22, 2006
  5. =?ISO-8859-15?Q?Andreas_Gr=E4ber?=

    Mouseover problem with tables....

    =?ISO-8859-15?Q?Andreas_Gr=E4ber?=, Jul 30, 2007, in forum: HTML
    Replies:
    8
    Views:
    406
    Bergamot
    Jul 31, 2007
Loading...

Share This Page