切换div $ this而不用同一个类切换另一个

时间:2014-02-17 19:47:15

标签: javascript jquery html

如何切换这个div .pane-content而不用同一个类切换另一个?

HTML:

<div class="pane">
   <div class="pane-header">Settings
  <div class="pane-controls">
        <span class="pane-toggle"><i class="fa fa-chevron-up"></i></span>
     <i class="fa fa-times"></i>
  </div>
  <div style="clear:both;"></div>
   </div>
   <div class="pane-content">
         Loreum Ipsum
   </div>
</div>

JS:

$('.pane-toggle').click(function () {
    $('.pane-content').toggle('fast');
    $("i", this).toggleClass("fa-chevron-down fa-chevron-up");
});

1 个答案:

答案 0 :(得分:1)

尝试 -

$('.pane-content',$(this).closest('.pane')).toggle('fast');

演示-----> http://jsfiddle.net/t5kM7/1/