jQuery:在已选择的元素内选择一个元素 [英] jQuery: Selecting an element in inside an already selected element

查看:66
本文介绍了jQuery:在已选择的元素内选择一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

$("table tr").click( function(event)
{
   //Say, here i want get the data of td element where its class name="special"
});

在点击事件中,是否可以选择一个元素,该元素是$("table tr")上方附加元素下面的元素?

Is there any way I can select a element while in the click event, a element under the attached element above $("table tr")?

推荐答案

在这种情况下,您可以执行以下操作:

In this specific case, you can do this:

$("table tr").click( function(event)
{
   $(this).children('td.special').whatEverYouNeed();
});

通常来说,您需要使用find():

Generally speaking, you need to use find():

$("table tr").click( function(event)
{
   $(this).find('td.special').whatEverYouNeed();
});

这篇关于jQuery:在已选择的元素内选择一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆