gpt4 book ai didi

jQuery closest() 不处理层次结构中的下一个元素

转载 作者:行者123 更新时间:2023-11-28 04:11:31 28 4
gpt4 key购买 nike

我有以下 html 结构:

<em class="help fa fa-question-circle text-muted"></em>
<div class="help-wrapper"></div>

当使用以下 JS 时,我认为它会很好,但它不起作用。没有错误或任何错误,只是行不通。

$('.help').on('click', function () {
$(this).closest('.help-wrapper').fadeToggle(300);
});

最佳答案

在上下文中使用nextsiblings

$('.help').on('click', function () {
$(this).next('.help-wrapper').fadeToggle(300);
});

 $('.help').on('click', function () {
$(this).siblings('.help-wrapper').fadeToggle(300);
});

关于jQuery closest() 不处理层次结构中的下一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25911296/

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