使用此功能,我没有正确代码的数量:请参阅附件。我无法理解为什么......
<script type="text/javascript">
$(document).ready(function(){
var $riepilogo = $('#riepilogo');
var $btn_riepilogo = $('#btn-riepilogo');
var parent_table;
var quantity;
var tot_quantity;
$btn_riepilogo.on('click',function(){
tot_quantity=0;
$('table',$riepilogo).html('<tr><th>Prodotto</th><th>Quantità (tot: <span id="tot-quantity"></span>)</th></tr>');
$('form input[type="text"]').each(function(){
quantity = parseInt($(this).val());
if(quantity > 0) {
tot_quantity+=quantity;
parent_table = $(this).parent().parent().parent();
$('table',$riepilogo).append('<tr><td>'+$('div:nth-child(2)',parent_table).text()+'</td><td>'+quantity+'</td></tr>');
$('#tot-quantity').html(tot_quantity);
}
});
$riepilogo.slideDown('fast');
return false;
});
});
</script>