0

如果您有以下代码:

 $('.object').has('span').each(function () {
    $(this).// do things to each match....
});

有没有一种简单的方法来定位 $(this) 的跨度?

就像是

$(this + 'span').//do things to span of current element

我几乎可以肯定这很容易做到,但我试着在谷歌上研究这个,但这些术语太笼统了,我很难找到任何参考!

4

2 回答 2

1

针对 $(this) 的跨度?

您可以使用find该选择器选择后代元素:

$(this).find("span")
// or
$("span", this)
于 2013-08-10T18:02:25.093 回答
1
$('.object').has('span').each(function() {
    $("span", this)..
});
于 2013-08-10T18:02:39.453 回答