Retrieve Table Row Index of Current Row

前端 未结 4 1465
执笔经年
执笔经年 2020-12-18 04:49

I am trying to validate a text input when it loses focus. I would like to know which row of the table it is in. This is what I have so far and it keeps coming back as unde

4条回答
  •  感情败类
    2020-12-18 05:07

    You are trying to use the DOM Core attribute on the jQuery object. Try this:

    alert(tableRow[0].rowIndex);

    @jandreas: from the W3C docs: rowIndex of type long, readonly, modified in DOM Level 2 This is in logical order and not in document order. The rowIndex does take into account sections (THEAD, TFOOT, or TBODY) within the table, placing THEAD rows first in the index, followed by TBODY rows, followed by TFOOT rows.

    .index() would not take those THEAD etc. into account.

提交回复
热议问题