使用$(this)的Jquery下一个相邻选择器

27 浏览
0 Comments

使用$(this)的Jquery下一个相邻选择器

如何在$(this)上使用相邻选择器“+”。

我需要帮助下面被注释掉的代码行 //this doesn\'t work:

$(".ExpandCollapse").click(function () {
            if ($(this).nextUntil('.Collapsable').is(':visible'))
            {
                //this doesnt work 
                $(this + ".Collapsable").hide();
            }
            else
            {
                //this doesnt work
                $(this + ".Collapsable").show();
            }
        });

能帮我一下吗?

提前谢谢。

最好的问候。

Jose

admin 更改状态以发布 2023年5月21日
0
0 Comments

您还可以缩减隐藏和显示的两个声明:

$(this).next().toggle();

0
0 Comments

使用next()

$(this).next(".Collapsable").hide();

或者简单地使用:

$(this).next().hide();

0