我正在研究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');
});
动态内容位于购物车信息下。我想显示项目并相应地隐藏它们。
答案 0 :(得分:1)
从display:none;
的子div中删除#cart-info
,否则它们将无法显示!
答案 1 :(得分:1)
在滑动父级之前只显示.shopp
元素:
$('.pull-right').on('click',function(){
alert( $('#cart-info').text());
$('#cart-info').find('.shopp').show(); //added line
$('#cart-info').slideToggle('slow');
});