ITPub博客

首页 > IT职业 > IT职场 > 改版后前端购物车系统

改版后前端购物车系统

IT职场 作者:w39 时间:2021-09-09 08:58:01 0 删除 编辑

图片描述



    


shopping

<!--这是商品-->
全选:
¥:0
结算
*{ margin: 0; padding: 0; font-family: "微软雅黑"; } #middle{ width:500px; height: 800px; border:1px solid black; margin: 0 auto; margin-top: 30px; position: relative; } .one{ width: 100%; height: 150px; border-bottom: 1px solid black; } .quan{ width:15px; height: 15px; line-height: 15px; text-align: center; color:#fff; border:1px solid red; border-radius:50%; position: relative; top:70px; left:15px; cursor: pointer; } .picture{ width:120px; height: 120px; line-height: 120px; text-align: center; font-size: 20px; background:goldenrod; float:left; margin-left: 100px; } .text{ width:170px; height: 112px; font-size: 16px; padding-top: 8px; float:right; margin-right: 100px; } .left,.right{ float:left; width:25px; height: 25px; font-size: 18px; border:1px solid red; position: relative; top:35px; cursor: pointer; text-align: center; margin-right: 10px; } .num{ float:left; width:25px; height: 25px; font-size: 18px; border:1px solid red; position: relative; top:35px; text-align: center; margin-right: 10px; } .result{ width:100%; height: 50px; line-height: 50px; border-top:2px solid brown; position: absolute; bottom: 0px; } .allText{ float: left; font-size:16px ; padding-left: 10px; } .all{ width:15px; height: 15px; line-height: 15px; text-align: center; color:#fff; border:1px solid red; border-radius:50%; float: left; cursor: pointer; margin-top:17px; margin-left: 10px; } .money{ float:right; width:160px; height: 100%; } .rmb{ font-size: 20px; float: left; } span.price{ margin-left: 5px; } .btn{ width:100px; height: 100%; text-align: center; background:brown; color:#fff; font-size: 18px; line-height: 50px; float: right; cursor: pointer; } #maskphoto{ width: 100%; height: 100%; position: absolute; top:0; background:#000; opacity: 0.6; z-index: 99; display: none; } .alert{ width:0; height: 0; position: fixed; left:50%; right:50%; top:50%; bottom: 50%; z-index:100; } .alert2{ width:300px; height: 160px; border:1px solid brown; border-radius: 5px; margin-left: -150px; margin-top: -80px; background:#fff; display: none; } .mmText{ width: 95%; height: auto; margin: 0 auto; text-align: center; padding: 20px 0; padding-top: 30px; } .bottom{ width:90%; height: 40px; margin: 0 auto; margin-top: 30px; } .btnLeft{ width:100px; height: 40px; float:left; background: brown; line-height: 40px; text-align: center; font-size: 17px; border-radius: 5px; color:#fff; cursor: pointer; } .btnRight{ width:100px; height: 40px; float:right; background: brown; line-height: 40px; text-align: center; font-size: 17px; border-radius: 5px; color:#fff; cursor: pointer; } var all = 0;//全选 var k = 0; $(function(){ twh(); }); function twh(){ var maindiv=$("#middle2"); maindiv.html(""); var str = ''; for(var i=1;i' + '
' + '
商品'+i+'元
' + '
' + '
这是件商品这是件商品这是件商品
-
0
+
' + '
' + '
' } maindiv.html(str); } function quan(i){ var result = $(".price").text(); //获取总金额 var num = $("#"+i).find(".num").text(); //获取相对应的数量 if($("#"+i).find(".quan").attr("alt")==0){ $("#"+i).find(".quan").css("background","red").attr("alt","1").text("√"); $(".price").text(parseInt(result)+i*num); k++; if(k==4){ $(".all").css("background","red").text("√"); all=1; } }else{ $("#"+i).find(".quan").css("background","none").attr("alt","0").text(""); $(".price").text(parseInt(result)-i*num); $(".all").css("background","none");//全选 k--; all=0; } } //点击减少 function left(i){ var num = $("#"+i).find(".num").text();//获取相对应的数量 var result = $(".price").text(); //获取总金额 num--; if(num

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/854/viewspace-2807537/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-12-14

  • 博文量
    92
  • 访问量
    268563