例如:
$("table tr").click( function(event)
{
//Say, here i want get the data of td element where its class name="special"
});
有什么方法可以让我在点击事件中选择一个元素,即 $("table tr")
上方附加元素下的一个元素?
最佳答案
在这种特定情况下,您可以这样做:
$("table tr").click( function(event)
{
$(this).children('td.special').whatEverYouNeed();
});
一般来说,你需要使用find()
:
$("table tr").click( function(event)
{
$(this).find('td.special').whatEverYouNeed();
});
关于javascript - jQuery:在已选元素中选择一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/629730/