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

Sos*_*osi 9 javascript jquery

我怎么能用$(this)使用相邻的选择器"+".

我需要帮助注释行//这不起作用:

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

你能帮我个忙吗?

非常感谢提前.

最好的祝福.

何塞

Sar*_*raz 12

使用 next()

$(this).next(".Collapsable").hide();
Run Code Online (Sandbox Code Playgroud)

或者干脆:

$(this).next().hide();
Run Code Online (Sandbox Code Playgroud)