PHP 商城中商品的加减

<div class="order_message clearfix">
    <div class="left_order">
        <img src="templates/default/images/order.jpg">
    </div>
    <div class="right_order">
       <p class="order_title">春夏套装</p>     
       <p class="bottom_content">
           <span class="price_Icon colors">¥</span><span class="details_price colors unitPrice">198</span>
           <span class="rf add_order">
               <span οnclick="reduce()" class="reduce"><img  src="templates/default/images/reduce3.png" /></span>
               <span class="numbers number">1</span>
               <span οnclick="addNumber()" class="addNumber"><img   src="templates/default/images/add1.png" /></span>
            </span>
        </p>
        <p class="all_order">
            <span class="rf">
                <span>总价</span>
                <span class="price_Icon">¥</span><span class="details_price all_nuber">198</span>
            </span>
            <span class="rf marginright02">
                <span>共&nbsp;</span><span class="number">1</span><span>&nbsp;件商品</span>
            </span>
        </p>
    </div>
</div>
<div class="sumbit">
    <p class="lf"><span>应付 ¥</span><span class="all_nuber"></span></p>
    <p class="rf">去付款</p>
</div>

<script src="templates/default/js/jquery-3.3.1.min.js"></script>
<script>
    function reduce(){
        var number=$(".number").html();
        if(number==1){
            statas1();
        }else{
            number--;
            var price=parseInt($(".unitPrice").html());
            var  allprice=number*price;
            $(".all_nuber").html(allprice);
            $(".number").html(number);
        }
    }
    function addNumber(){
        var number=$(".number").html();
        //获取库存
        var Stock=8;
        if(number>=Stock){

        }else{
            number++;
            statas();
            var price=parseInt($(".unitPrice").html());
            var  allprice=number*price;
            $(".all_nuber").html(allprice);
            $(".number").html(number);
        }
    }
    // 如果商品数大于一,替换减号状态
    function statas(){
        $(".reduce img").attr("src","templates/default/images/reduce2.png");
    }
    function statas1(){
        $(".reduce img").attr("src","templates/default/images/reduce3.png");
    }

</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值