0

我正在研究 jquery,我正在尝试在动态内容上使用 slideToggle,但我无法制作幻灯片。怎样才能让它正常工作?我将为您提供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');
});

动态内容在购物车信息下。我想显示这些项目并相应地隐藏它们。

4

2 回答 2

1

删除display:none;子 div 的#cart-info,否则它们不会显示!

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

于 2013-09-18T13:42:27.563 回答
1

只需.shopp在滑动父级之前显示元素:

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

});

现场演示:http: //jsfiddle.net/P3WaC/2/

于 2013-09-18T13:44:38.973 回答