locked
hide all div after certain div RRS feed

  • Question

  • User81789783 posted
    <div id="treetopic"><div class="glyphicon glyphicon-plus" id="div_one">one<div class="treetopicheader" id="div_onetopic" one=""><span>topic one</span></div></div><p></p><div class="glyphicon glyphicon-plus" id="div_two">two<div class="treetopicheader" id="div_twoone" of="" two=""><span>one of two</span></div><div class="treetopicheader" id="div_twotwo" of="" two=""><span>two of two</span></div></div><p></p><div class="glyphicon glyphicon-plus" id="div_three">three</div><p></p></div>

    i have above code and i want when user click on glyphicon-plus class i.e plus icon it should hide all child div in it .. for example one has single child in above code and two has two child

    i write below code

     $(".glyphicon-plus").click(function () {
                  //  alert()
                    $(".glyphicon-plus").nextUntil("div", "p").hide();
                    // $(ele).append('<span>' +"   "+  $(ele).nextUntil("div.header").filter("p").length +'</span' )
                    //$(ele).append('<span>' + "   " + $(ele).nextUntil("div.header").filter("p").length + '</span')
                })

    Sunday, March 31, 2019 2:17 PM

All replies

  • User-2054057000 posted

    Hi Erum,

    You can use jQuery Children method in this scenario;

    $(".glyphicon-plus").click(function () {
    
        $(this).children().hide(); 
    
    });

    Monday, April 1, 2019 4:47 AM