gpt4 book ai didi

javascript - wrapAll 和 andSelf 不包装 self 元素

转载 作者:行者123 更新时间:2023-11-28 00:20:56 25 4
gpt4 key购买 nike

我使用下面的代码:

$('.graph-img').each(function(index) {
$(this).prev('h2,h3,h4,h5,h6,p').prevUntil('.graph-img').andSelf().not('h1').wrapAll("<div class='prevent-break'>");
});

它包装了所有元素,但不包括当前引用的 .graph-img 。有什么想法吗?

最佳答案

andSelf 不会添加第一元素集,而是添加前一个元素。

您可以在此处使用.add(this)

请注意andSelf已被弃用,取而代之的是 addBack,其名称误导性较小。

关于javascript - wrapAll 和 andSelf 不包装 self 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30033999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com