Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery next adjacent selector with $(this)

How could i use the adjacent selector "+" with the $(this).

I would need a help with the commented lines with //this doesnt work:

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

Could you give me a hand?

Thanks a lot in advance.

Best Regards.

Jose

like image 543
Sosi Avatar asked Aug 05 '10 09:08

Sosi


1 Answers

Use next()

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

Or simply:

$(this).next().hide();
like image 62
Sarfraz Avatar answered Oct 15 '22 21:10

Sarfraz