最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get first TD of THIS row - Stack Overflow

programmeradmin0浏览0评论

Fairly easy yet i did not find how to do this online.

I want the first TD of the this element (row)

$(document).on("click", "#posTable tr", function() { 

    alert($(this).('td:first').text());

});

i tried:

alert($(this).('td:first').text());
alert($('td:first', $(this).parents('tr')).text()));

Fairly easy yet i did not find how to do this online.

I want the first TD of the this element (row)

$(document).on("click", "#posTable tr", function() { 

    alert($(this).('td:first').text());

});

i tried:

alert($(this).('td:first').text());
alert($('td:first', $(this).parents('tr')).text()));
Share Improve this question edited Nov 13, 2013 at 11:40 Mr. Polywhirl 48.8k12 gold badges93 silver badges144 bronze badges asked Nov 13, 2013 at 11:37 FaarbhurtzFaarbhurtz 5801 gold badge8 silver badges27 bronze badges 2
  • $(this).find('td:first') – Ramesh Commented Nov 13, 2013 at 11:38
  • possible duplicate of Jquery- Get the value of first td in table – Daniel Klöck Commented Nov 13, 2013 at 11:41
Add a ment  | 

1 Answer 1

Reset to default 7

You need to use find() to get the first td in the given row. You can also pass this in selector as a context.

Using find()

alert($(this).find('td:first').text());

Using jQuery( selector [, context ] )

alert($('td:first', this).text());
发布评论

评论列表(0)

  1. 暂无评论