gpt4 book ai didi

javascript - 以任何一种方式包装元素

转载 作者:行者123 更新时间:2023-11-30 13:14:43 24 4
gpt4 key购买 nike

$('.single-post .post-content').not(':contains(.gallery)').find('.lightbox').wrapAll('<ul class="gallery"><li class="gallery-item">');

我希望它仅在找不到“画廊”时才换行,但无论哪种方式都换行,我做错了什么?

最佳答案

contains 选择包含特定文本的元素而不是那些具有特定元素的元素,您可以改用 :has 选择器:

$('.single-post .post-content:not(:has(.gallery)) .lightbox').wrapAll('<ul class="gallery"><li class="gallery-item">');

关于javascript - 以任何一种方式包装元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12464716/

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