简体   繁体   English

对动态内容进行幻灯片切换

[英]Slidetoggle on dynamic content

I am working on jquery and I am trying to use slideToggle on dynamic content but I cannot make it up slide. 我正在研究jquery,我正在尝试在动态内容上使用slideToggle,但我无法将其滑动。 How could make it work properly? 怎么能让它正常工作? I will provide you the http://jsfiddle.net/P3WaC/ 我会为你提供http://jsfiddle.net/P3WaC/

<li class="pull-right">
<div class="text-righ padding-right">
    <div class="chart">My cart (<span class="item_cart">3</span>)</div>
    <button class="btn btn-warning">CHECKOUT</button>
    <input type="text" class="input-large light-panel active-tab-search" placeholder="Search rewards">
</div>
<div id="cart-info" style="display: none;">
    <div id="each-2" class="shopp" style="display: none;">
        <div class="label">Gift voucher</div>
        <div class="shopp-price">$<span class="itempr">20</span>
        </div><span>Quantity: </span><span class="shopp-quantity">2</span>
        <img src="../img/erop/remove.png" class="remove">
        <br class="all">
    </div>
    <div id="each-3" class="shopp" style="display: none;">
        <div class="label">Gift voucher</div>
        <div class="shopp-price">$<span class="itempr">10</span>
        </div><span>Quantity: </span><span class="shopp-quantity">1</span>
        <img src="../img/erop/remove.png" class="remove">
        <br class="all">
    </div>
</div>

$('.pull-right').on('click',function(){
    alert( $('#cart-info').text()); 
    $('#cart-info').slideToggle('slow');
});

The dynamic content is under cart-info. 动态内容在cart-info下。 I want to display the items and hide them accordingly. 我想显示项目并相应地隐藏它们。

Remove display:none; 删除display:none; off the child div's of #cart-info , or else they won't show! 关闭#cart-info的子div,否则他们将无法显示!

Demo: http://jsfiddle.net/tymeJV/P3WaC/1/ 演示: http//jsfiddle.net/tymeJV/P3WaC/1/

Just show the .shopp elements before sliding the parent: 只需在滑动父级之前显示.shopp元素:

$('.pull-right').on('click',function(){
    alert( $('#cart-info').text()); 
    $('#cart-info').find('.shopp').show();  //added line
    $('#cart-info').slideToggle('slow');

});

Living demo: http://jsfiddle.net/P3WaC/2/ 生活演示: http//jsfiddle.net/P3WaC/2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM