更新时间:2023-01-08 08:16:49
如果要包括文本节点,则需要使用contents()
并弄清相对于其父级的.son
索引:>
If you want to include text nodes, you will need to use contents()
and figure out the index of .son
in relation to its parent:
var $contents = $(".mother").contents();
var sonIdx = $contents.index($(".son"));
var elements = $contents.filter(function(i) {
return i > sonIdx;
}).get();
这是一个小提琴,它可以演示.