有没有办法检查a child div是否是第一项parent div?
例如:
<div id="parent">
Some text <--------- not the first thing in the div
<div id="child"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
要么
<div id="parent">
<div id="child"></div> <--------- is the first thing in the div
Some text
</div>
Run Code Online (Sandbox Code Playgroud)
就像是
var isFirst = $('#child').is($('#parent').contents().filter(function () {
return this.nodeType != 3 || $.trim(this.nodeValue) != ''
}).first())
Run Code Online (Sandbox Code Playgroud)
几乎没有条件要检查
| 归档时间: |
|
| 查看次数: |
31 次 |
| 最近记录: |