http://jsfiddle.net/673h38g9/14/
当点击加号图标和减号图标时,我正在计算并将其添加到myOrderPanel_footer div。
如果在同一个项目上单击加号图标,我不想增加数量
如何检查项目是否不存在,那么我只想增加数量
单击加号图标时的示例逻辑
$(document).on('click', '.icon-plus', function (e) {
var value = parseInt($(this).closest('div').find('.QtyInput').val());
$(this).closest('div').find('.QtyInput').val(value+1);
var currentsellprice = parseFloat($(this).parent().prev().data('sellprice')); // get the data "price" of item
var currentquantity =parseInt($(this).closest('div').find('.QtyInput').val());
$(this).closest('.lastItm_Wrap').find('.Itm_right_aside .sellprice').text(currentsellprice*currentquantity);
if(currentquantity>=1)
{
addquantitytoMyordersfooter();
var subtotalvalue = parseInt($(".myOrderPanel_footer .subtotal").data('subtotal'));
subtotalvalue = subtotalvalue + currentsellprice ;
$(".myOrderPanel_footer .subtotal").data('subtotal',subtotalvalue);
$(".myOrderPanel_footer .subtotal").text(subtotalvalue)
}
displaylogicforfooter();
});
如果我维护一个全局数组,或者还有其他可行的解决方案来解决这个问题,我需要你的建议吗?