【发布时间】:2015-09-08 17:44:34
【问题描述】:
考虑到 2 个备选方案
<div class="no-text example">
100
</div>
<div class="with-text example">
<span class="surprise"> 50 </span>
100
</div>
我希望在这两种情况下都使用相同的选择器或以某种方式知道.no-text 和.with-text 之间的区别.example 中的数字
做$(".example").text()会给我50 100
目前我正在尝试使用.clone().children().remove().end().text(),但我需要以某种方式知道它是.no-text 和.with-text
【问题讨论】:
-
$('.example').children().length? -
@AndreasEriksson 可以工作,我会测试更多的测试用例
标签: javascript jquery jquery-selectors