Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery下一个相邻的选择器,带有$(this)_Javascript_Jquery - Fatal编程技术网

Javascript Jquery下一个相邻的选择器,带有$(this)

Javascript Jquery下一个相邻的选择器,带有$(this),javascript,jquery,Javascript,Jquery,如何将相邻的选择器“+”与$(this)一起使用 我需要一个注释行的帮助//这不起作用: $(".ExpandCollapse").click(function () { if ($(this).nextUntil('.Collapsable').is(':visible')) { //this doesnt work $(this + ".Collapsable").hide();

如何将相邻的选择器“+”与$(this)一起使用

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

$(".ExpandCollapse").click(function () {
            if ($(this).nextUntil('.Collapsable').is(':visible'))
            {
                //this doesnt work 
                $(this + ".Collapsable").hide();
            }
            else
            {
                //this doesnt work
                $(this + ".Collapsable").show();
            }
        });
你能帮我一下吗

先谢谢你

致以最良好的祝愿

何塞

使用

或者简单地说:

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

您还可以减少使用两条语句来隐藏和显示:

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

这是对调用的
DOM元素的引用。您不能将
字符串
添加到该字符串中

因此,您可以直接使用
对其进行操作

$(this).hide();
或者您也可以从那里遍历
DOM

$(this).next().hide();
$(this).prev().hide();
$(this).closest('.Collapsable').hide();
// another 200 methods
$(this).next().hide();
$(this).prev().hide();
$(this).closest('.Collapsable').hide();
// another 200 methods