且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在另一个div中的一个div之后获取内容

更新时间: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();

这是一个小提琴,它可以演示.