开发者

Getting the row of the table cell that was just clicked

开发者 https://www.devze.com 2023-03-11 01:42 出处:网络
I have the foll开发者_开发知识库owing: $(\'tbody\').delegate(\'td\',\'click\',function() { log($(this).index()); // Column

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

精彩评论

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