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.
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.
Share Improve this question asked Jul 11, 2013 at 12:27 LukasLukas 7,73420 gold badges79 silver badges127 bronze badges3 Answers
Reset to default 8$(this).parent().next('.panel').slideDown(100);
should do the trick
You just need to go up one level, and there is no child
method:
open_bt.on('click',function(){
$(this).parent().next('.panel').slideDown(100);
});
You can do this:
open_bt.on('click', function () {
$(this).closest('div').next('.panel').slideDown(100);
});