Javascript 在jQuery中使用过滤器
但这表明我没有定义。如何从当前DIV获取当前站点Javascript 在jQuery中使用过滤器,javascript,jquery,html,css,Javascript,Jquery,Html,Css,但这表明我没有定义。如何从当前DIV获取当前站点 LIVE:使用过滤器方法从结果中过滤出特定项,如果要使用查找方法在结果中查找元素的子元素: $(".click").click(function(){ alert($(this).parent().filter("[title=here]").attr('href')); }) 如果您有所有的孩子,并且希望保留一个特定的孩子,那么将使用过滤器方法。例如: alert($(this).parent().find("[title=here]")
LIVE:使用
过滤器
方法从结果中过滤出特定项,如果要使用查找
方法在结果中查找元素的子元素:
$(".click").click(function(){
alert($(this).parent().filter("[title=here]").attr('href'));
})
如果您有所有的孩子,并且希望保留一个特定的孩子,那么将使用
过滤器方法。例如:
alert($(this).parent().find("[title=here]").attr('href'));
.filter()
不获取子节点
如果只想查看下一级的子节点,请使用.children(“[title=here]”)
要搜索所有子代节点,请使用.find(“[title=here]”)
alert($(this).parent().find("[title=here]").attr('href'));
alert($(this).parent().children().filter("[title=here]").attr('href'));