开发者

Getting the row of the table cell that was just clicked

I have the foll开发者_开发知识库owing:

$('tbody').delegate('td','click',function() {
    log($(this).index()); // Column
});

Q: How do I determine the row?


Use the .parent() method.

$('tbody').delegate('td','click',function() {
  $(this).parent(); // tr
});

Or you can use:

  • .closest()
    Traverse up the tree, starting at current element.
  • .parents()
    Traverse up the tree starting with parent element.


parent() is maybe what you are looking for. Like this:

$(this).parent()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜