0
$('.rs-expand').hide();
$('.rs-details').click(function(){
    $('.rs-expand').slideUp('fast');
    $('.rs-s li').removeClass('toggled');
    $(this).parent().find('.rs-expand').toggle('blind', 200);
    $(this).parent().addClass('toggled');
});

我在哪里添加或如何添加,如果再次单击,它将向上滑动?

HTML

<ul class="rs-s">
  <li> 
    <div class="rs-details">
      <h2>Lorem ipsum dolor sit amet</h2>
      <div class="rs-expand"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div>
    </div>
  </li>
</ul>
4

3 回答 3

3
$('.rs-expand').hide();
$('.rs-details').click(function(){
    $('.rs-expand').slideUp('fast');
    $(this).children('.rs-expand').slideToggle('fast');
});

http://jsfiddle.net/B4Kjs/2/

于 2012-06-18T15:36:34.830 回答
1
$('.rs-details').toggle(function(){
    $(this).find('div').slideToggle('fast');
    $(this).parent('li').removeClass('toggled');
  },
  function() {
    $(this).find('div').slideToggle('fast');
    $(this).parent('li').addClass('toggled');
  });

JSFiddle
http://jsfiddle.net/B4Kjs/

于 2012-06-18T15:43:51.773 回答
0

修改后的代码。这应该会减少您的需求。

CSS样式:

.rs-expand {
    display: none;
}

jQuery:

$('.rs-details').click(function(){
    $('.rs-expand').slideToggle('fast');
});

在这里看小提琴

于 2016-08-05T04:39:55.850 回答