无法与.wrapall()一起包含Lottie-player标签

发布于 2025-01-22 09:19:03 字数 1069 浏览 4 评论 0原文

每次在此代码上都有H2 on 文章我将所有内容从h2中获取,直到下一个h2 h2 并将其包装在上。

<article>
 <h2>Lottie Files</h2>
 <div class='lottie-wrapper>
   <lottie-player src='' background="transparent" speed="1"></lottie-player>
  </div>
</article>
$('article h2').each(function () {
  $(this).nextUntil('h2').addBack().wrapAll('<section />')
})

但是由于某种原因,如果有&lt; lottie-player&gt;标签,则代码将其从DOM中删除。

仅当我将lottiefiles Interactivity脚本与上述片段

https://unpkg.com/@lottiefiles/lottie-interactive@latest/dist/dist/lottie-interactivity.min.min.min.js

这是 时,才发生这种情况。仅在简单的HTML上进行WordPress上发生并不是问题。

如果我从包装纸上删除一个名为.lottie-wrapper的父级div,则可以直接调用lottie-player

$('article h2').each(function () {
  $(this)
    .nextUntil('h2')
    .addBack()
    .not('.lottie-wrapper')
    .wrapAll('<section />')
})

标签播放器里面

On this code each time there is an h2 on article I take all of the content from the h2 till the next h2 and wrap it on a section.

<article>
 <h2>Lottie Files</h2>
 <div class='lottie-wrapper>
   <lottie-player src='' background="transparent" speed="1"></lottie-player>
  </div>
</article>
$('article h2').each(function () {
  $(this).nextUntil('h2').addBack().wrapAll('<section />')
})

But for some reason if there is the <lottie-player> tag, the code removes it from the DOM.

It only happens when I include lottieFiles interactivity script in conjunction with the above snippet

https://unpkg.com/@lottiefiles/lottie-interactivity@latest/dist/lottie-interactivity.min.js

This is happening on WordPress only on a simple html is not a problem.

If I remove a parent div called .lottie-wrapper from the wrap then it works, but not just calling the lottie-player tag directly

$('article h2').each(function () {
  $(this)
    .nextUntil('h2')
    .addBack()
    .not('.lottie-wrapper')
    .wrapAll('<section />')
})

But of course I want the lottie-player inside

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末が日狂欢 2025-01-29 09:19:03

这很奇怪,只有在WordPress上发生,并且只有当我使用脚本

https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js

以及jQuery wrapall()。我通过使用旧版本的脚本https://unpkg.com/@lottiefiles/ [email&nbsp; prectioned] /dist/lottie-player.js

This was pretty bizarre, it only happened on WordPress and only when I use the script

https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js

Together with the jQuery wrapAll(). I fixed it by using an older version of the script https://unpkg.com/@lottiefiles/[email protected]/dist/lottie-player.js

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文