5

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.

4

3 回答 3

8

$(this).parent().next('.panel').slideDown(100);应该做的伎俩

于 2013-07-11T12:29:44.670 回答
3

你只需要上一层,没有child办法:

open_bt.on('click',function(){
   $(this).parent().next('.panel').slideDown(100);
});
于 2013-07-11T12:28:50.523 回答
3

你可以这样做:

open_bt.on('click', function () {
    $(this).closest('div').next('.panel').slideDown(100);
});
于 2013-07-11T12:28:53.667 回答