老师,好。控制这个+ -js代码在哪个js文件下??
$(".minus").click(function(){
var cartid = $("input[name=productnum]").attr('id');
var num = parseInt($("input[name=productnum]").val()) - 1;
if (parseInt($("input[name=productnum]").val()) <= 1) {
var num = 1;
}
var total = parseFloat($(".value.pull-right span").html());
var price = parseFloat($(".price span").html());
changeNum(cartid, num);
var p = total - price;
if (p < 0) {
var p = "0";
}
$(".value.pull-right span").html(p + "");
$(".value.pull-right.ordertotal span").html(p + "");
});
$(".plus").click(function(){
var cartid = $("input[name=productnum]").attr('id');
var num = parseInt($("input[name=productnum]").val()) + 1;
var total = parseFloat($(".value.pull-right span").html());
var price = parseFloat($(".price span").html());
changeNum(cartid, num);
var p = total + price;
$(".value.pull-right span").html(p + "");
$(".value.pull-right.ordertotal span").html(p + "");
});
function changeNum(cartid, num)
{
$.get('$url', {'productnum':num, 'cartid':cartid}, function(data){
location.reload();
});
}
我在detial文件下面新写的js貌似没有生效,无法触发事件,删除了