3 javascript jquery jquery-selectors
我有以下HTML:
<div class="test">
First
<p></p>
Second
<p></p>
Third
</div>
Run Code Online (Sandbox Code Playgroud)
Second在这种情况下我怎么能得到这个词?
您可以使用jQuery contents()和eq():
var second = $('.test').contents().filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).eq(1).text();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
195 次 |
| 最近记录: |