Search code examples
javascriptjqueryparent-childparent

How to find an element outside its parent with jQuery


I have this markup:

  <div>
    <div>
      <button class="button"></button>
    </div>
    <div class="panel">
    </div>
  </div>

Now i need to find next panel just right for button element and make some action on it. So i do this but something is not right, can anybody help?

var open_bt = $('.button');

open_bt.on('click',function(){
   $(this).parent().parent().next().child('.panel').slideDown(100);
});

Thx for help.


Solution

  • $(this).parent().next('.panel').slideDown(100); should do the trick