2011-10-23 80 views

回答

4

使用下面的代码。使用html()代替.text(),以仅匹配不包含其他元素的跨度。

<span><span>a</span></span> <--text方法将选择两个跨度元素。

$("span").filter(function(){ 
    return $(this).html() == "a"; 
}) 
+0

只有1.4 + –

+1

@RoyiNamir根据http://api.jquery.com/filter/,此功能可在1.0+ –

+0

对不起,我感到困惑。 –