项目展示效果

实现添加购物鞋数量总金额自动变化

实现连接购物车功能

实现在购物车里收藏与删除

下面是购物页面代码

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>购买精选</title><style type="text/css">
body{width: 1350px;height: 100%;}#div0{width: 100%;height: 2100px;}
#div1{width: 35%;height: 100px;float: left;}
#div2{width: 65%;height: 100px;float: left;}
#div2 ul{margin: 40px;}
#div2 ul li{float: left;list-style: none;width: 20%;font-size: 20px;color: #789;}
#div2 ul li a{text-decoration:none; color: gray;}
#div2 ul li:hover{color: black;}
#div3{width: 10%;height: 2000px;float: left;}
#div4{width: 80%;height: 400px;float: left;}
#div4 ul li{width: 20%;list-style: none;float: left;margin: 2%;}
#div4 ul li:hover{transform: translate(0,10px);}
#div6{width: 80%;height: 400px;float: left;}
#div6 ul li{width: 20%;list-style: none;float: left;margin: 2%;}
#div6 ul li:hover{transform: translate(0,10px);}
#div7{width: 80%;height: 400px;float: left;}
#div7 ul li{width: 20%;list-style: none;float: left;margin: 2%;}
#div7 ul li:hover{transform: translate(0,10px);}
#div8{width: 80%;height: 400px;float: left;}
#div8 ul li{width: 20%;list-style: none;float: left;margin: 2%;}
#div8 ul li:hover{transform: translate(0,10px);}
#div9{width: 80%;height: 400px;float: left;}
#div9 ul li{width: 20%;list-style: none;float: left;margin: 2%;}
#div9 ul li:hover{transform: translate(0,10px);}
#div10{position: fixed;top: 100px;right:10px;width: 50px;height: 400px;background: black;}
#div10 ul{padding: 10px;}
#div10 ul li{list-style: none;height: 100px;}
#div10 ul li img:hover{background: orange;}</style><script type="text/javascript">//减法function minus(index) {//获取当前数量的值var amounts=document.getElementsByName("amount");//得到第一个amount的元素的value属性的值var count=parseInt(amounts[index].value); //数量加1if (count<=1){alert("不能再减了,快没了!!");} else {//得到第一个amount的元素的value属性的值var count=parseInt(amounts[index].value)-1; //数量加1//重新把count的值绑定在数量文本框里amounts[index].value=count;var prices=document.getElementsByName("price");var price=parseFloat(prices[index].value);//乘以Math.pow(10,2)的原因为避免失真var totalMoney=((price*Math.pow(10,2))*count)/Math.pow(10,2);document.getElementById("price"+index).innerHTML="¥:"+totalMoney;}total();}//加法function plus(index) {//获取当前数量的值var amounts=document.getElementsByName("amount");//得到第一个amount的元素的value属性的值var count=parseInt(amounts[index].value)+1; //数量加1//重新把count的值绑定在数量文本框里amounts[index].value=count;//当前操作端口的价格也要重新计算//得到当前端口的单价var prices=document.getElementsByName("price");var price=parseFloat(prices[index].value);//乘以Math.pow(10,2)的原因为避免失真var totalMoney=((price*Math.pow(10,2))*count)/Math.pow(10,2);//把当前价格显示在文本中document.getElementById("price"+index).innerHTML="¥:"+totalMoney;total();}//求总金额function total() {//得到所有的数量var counts=document.getElementsByName("amount");//得到所有的单价var prices=document.getElementsByName("price");var sumMoney=0;for (var i=0;i<counts.length;i++){//乘以Math.pow(10,2)的原因为避免失真sumMoney+=(parseFloat(prices[i].value)*Math.pow(10,2)*parseInt(counts[i].value)/Math.pow(10,2));}//把总金额显示再指定的元素中document.getElementById("totalPrice").innerHTML="¥:"+sumMoney;}//加入收藏function save() {if (confirm("确认要收藏吗?")){alert("收藏成功!");}}//删除function delete1() {if (confirm("确认要删除吗?")) {var del=document.getElementById("first");del.parentNode.removeChild(del);alert("删除成功!!");}}
</script></head>
<body>
<div id="div0"><a name="gouwu"></a>
<div id="div1"><img src="data:images/youxuan.png" width="200px"></div>
<div id="div2"><ul><li><b><a href="../高贵宝/web-16.1.html#sy">首页</b></li><li><b><a >购买精选</a></b></li><li><b><a href="../高贵宝/web-16.2.html#shequ">社区精选</a></b></li><li><b><a href="../赵江波/商家入驻.html"">商家入驻</a></b></li><li><b><a href="../邓/建议.html#guanyu">关于我们</a></b></li></ul>
</div>
<div id="div3"></div>
<div id="div4"><h2>Jordan</h2><figure><ul><li><img src="data:images/xie4.jpg" width="150px"><figcaption>Nike/耐克AIR JORDAN 1 男女篮球鞋AJ1黑紫脚趾553558-125紫葡萄
</figcaption>
¥:<input type="text" name="price" value="1299" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price0">¥:1299</font><br>
<input type="button"  value="+" name="plus" onclick="plus(0)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(0)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li><li><img src="data:images/xie3.jpg" width="150px"><figcaption>
Nike/耐克AIR JORDAN 1 MID女子篮球鞋AJ1玫瑰金555112-190中帮</figcaption>
¥:<input type="text" name="price" value="1549" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price1">¥:1549</font><br>
<input type="button"  value="+" name="plus" onclick="plus(1)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(1)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li><li><img src="data:images/xie2.jpg" width="150px"><figcaption>Nike/耐克AIR JORDAN 1 男女AJ1薄荷绿3M篮球鞋CQ9828-131 郭艾伦
</figcaption>
¥:<input type="text" name="price" value="2799" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price2">¥:2799</font><br>
<input type="button"  value="+" name="plus" onclick="plus(2)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(2)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li><li><img src="data:images/xie1.jpg" width="150px"><figcaption>Nike/耐克AIR JORDAN 1 MID女子篮球鞋AJ1糖果鸳鸯554725-083拼色
</figcaption>
¥:<input type="text" name="price" value="3200" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price3">¥:3200</font><br>
<input type="button"  value="+" name="plus" onclick="plus(3)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(3)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li></ul></figure>
</div>
<div id="div6">
<h2>Nike</h2>
<figure>
<ul>
<li><img src="data:images/xie5.jpg" width="150px"><figcaption>Nike耐克官方AIR FORCE 1 MID '男子运动鞋空军一号板鞋
传世风尚 </figcaption>
¥:<input type="text" name="price" value="721" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price4">¥:721</font><br>
<input type="button"  value="+" name="plus" onclick="plus(4)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(4)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie6.jpg" width="150px"><figcaption>Nike耐克官方NIKE ZOOM FLY 3 男子跑步鞋马拉松缓震回弹 AT8240</figcaption>¥:<input type="text" name="price" value="789" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price5">¥:789</font><br>
<input type="button"  value="+" name="plus" onclick="plus(5)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(5)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie7.jpg" width="150px"><figcaption>Nike耐克官方AIR MAX 270 REACT女子运动鞋休闲鞋气垫鞋DC3276</figcaption>
¥:<input type="text" name="price" value="1039" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price6">¥:1039</font><br>
<input type="button"  value="+" name="plus" onclick="plus(6)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(6)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie8.jpg" width="150px"><figcaption>Nike耐克官方FREE RN 5.0 2020 女子跑步鞋运动鞋慢跑鞋CJ0270</figcaption>
¥:<input type="text" name="price" value="379" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price7">¥:379</font><br>
<input type="button"  value="+" name="plus" onclick="plus(7)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(7)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
</ul>
</figure>
</div>
<div id="div7"><h2>LI-NING</h2>
<figure>
<ul>
<li><img src="data:images/xie9.jpg" width="150px"><figcaption>李宁羽毛球鞋男鞋情侣鞋男士鞋子专业防滑低帮运动鞋</figcaption>
¥:<input type="text" name="price" value="288" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price8">¥:288</font><br>
<input type="button"  value="+" name="plus" onclick="plus(8)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(8)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie10.jpg" width="150px"><figcaption>李宁旗舰官网男鞋2020新款全能王鞋子低帮运动鞋</figcaption>
¥:<input type="text" name="price" value="208" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price9">¥:208</font><br>
<input type="button"  value="+" name="plus" onclick="plus(9)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(9)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie11.jpg" width="150px"><figcaption>李宁羽毛球鞋女鞋耐磨防滑女士鞋子低帮运动鞋</figcaption>
¥:<input type="text" name="price" value="228" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price10">¥:228</font><br>
<input type="button"  value="+" name="plus" onclick="plus(10)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(10)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie12.jpg" width="150px"><figcaption>李宁羽毛球鞋男鞋专业防滑鞋子男士低帮运动羽毛球鞋</figcaption>
¥:<input type="text" name="price" value="238" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price11">¥:238</font><br>
<input type="button"  value="+" name="plus" onclick="plus(11)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(11)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
</ul>
</figure>
</div>
<div id="div8">
<h2>PUMA</h2>
<figure>
<ul>
<li><img src="data:images/xie13.jpg" width="150px"><figcaption>PUMA彪马官方新款女子经典休闲鞋 SMASH </figcaption>
¥:<input type="text" name="price" value="269" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price12">¥:269</font><br>
<input type="button"  value="+" name="plus" onclick="plus(12)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(12)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie14.jpg" width="150px"><figcaption>PUMA彪马官方 男女同款情侣SEGA联名款休闲鞋 </figcaption>
¥:<input type="text" name="price" value="429" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price13">¥:429</font><br>
<input type="button"  value="+" name="plus" onclick="plus(13)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(13)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie15.jpg" width="150px"><figcaption>PUMA彪马官方正品 刘雯同款新款女子复古休闲鞋 </figcaption>
¥:<input type="text" name="price" value="809" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price14">¥:809</font><br>
<input type="button"  value="+" name="plus" onclick="plus(14)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(14)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie16.jpg" width="150px"><figcaption>PUMA彪马官方正品 男女同款复古经典德训鞋休闲鞋 </figcaption>
¥:<input type="text" name="price" value="197" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price15">¥:197</font><br>
<input type="button"  value="+" name="plus" onclick="plus(15)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(15)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
</ul>
</figure>
</div><div id="div9">
<h2>VANS</h2>
<figure>
<ul>
<li><img src="data:images/xie17.jpg" width="150px"><figcaption>【燃冬季】Vans范斯官方黑白棋盘格宽条纹男鞋女鞋低帮板鞋运动鞋</figcaption>
¥:<input type="text" name="price" value="463" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price16">¥:463</font><br>
<input type="button"  value="+" name="plus" onclick="plus(16)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(16)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie18.jpg"  width="150px"><figcaption>【燃冬季】Vans范斯官方 黑色男鞋女鞋低帮职业滑板鞋
</figcaption>
¥:<input type="text" name="price" value="660" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price17">¥:660</font><br>
<input type="button"  value="+" name="plus" onclick="plus(17)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(17)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie19.jpg"  width="150px"><figcaption>【燃冬季】Vans范斯官方灰色Vans解构小香风男女SK8-Hi高帮板鞋</figcaption>
¥:<input type="text" name="price" value="465" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price18">¥:465</font><br>
<input type="button"  value="+" name="plus" onclick="plus(18)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(18)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
<li><img src="data:images/xie20.jpg"  width="150px"><figcaption>【燃冬季】Vans范斯官方 灰色侧边条纹男女Old Skool低帮板鞋</figcaption>
¥:<input type="text" name="price" value="423" style="width: 60px;">
&nbsp;&nbsp;&nbsp;&nbsp;
<font id="price19">¥:423</font><br>
<input type="button"  value="+" name="plus" onclick="plus(19)">
<input type="text" style="width: 20px;" name="amount" value="1">
<input type="button"  value="-" name="minus" onclick="minus(19)"><br>
<font onclick="save()">移入收藏</font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font onclick="delete1()">删除</font>
</li>
</ul>
</figure>
</div>
<div id="div10">
<ul>
<li><a href="../邓/dengru.html#dr"><img src="data:images/yonghu.png" width="30px"></a></li>
<li><a href="购物车.html#gouwuche"><img src="data:images/gouwu.png" width="30px" ></a></li>
<li><a href="../邓/建议.html#guanyu"><img src="data:images/lianxi.png" width="30px"></a></li>
<li><a href="../邓/建议.html#guanyu"><img src="data:images/shezhi.png" width="30px"></a></li>
</ul>
</div></div>
</body>
</html>

下面是购物车页面

<!DOCTYPE html>
<html>
<head lang="en"><meta charset="UTF-8"><title>完善当当购物车页面</title><style type="text/css">body,ul,li,div,p,h1,h2,ol{margin: 0;padding: 0;}
ul,li,ol{list-style: none;}
.content{width: 810px; margin: 0 auto;  font-family: "微软雅黑";}
.logo{margin: 10px 0;}
.logo span{display: inline-block;float: right;width: 60px;height: 30px;line-height: 30px;font-size: 14px;background: #ff0000;color: #ffffff;text-align: center;border-radius: 10px;margin-top: 5px;margin-right: 10px;cursor: pointer;font-weight: bold;
}
.cartList{/*background: url("../image/02.jpg") no-repeat;*//*height: 414px;*/overflow: hidden;
}
.cartList ul{display: flex;justify-content: space-between;/*float: right;*//*width: 450px;*/
}
.cartList ul:nth-of-type(1){display: flex;margin-top: 125px;
}
.cartList ul:nth-of-type(2){margin: 20px 0;
}
.cartList ul li{font-family: "微软雅黑";font-size: 12px;color: #666666;text-align: center;line-height: 25px;/*float: left;*/
}
.cartList ul li input[name="price"]{border: none;background: transparent;width: 45px;text-align: center;
}
.cartList ul li input[name="amount"]{width: 45px;text-align: center;border: 1px solid #999999;border-left: none;border-right: none;height: 21px;
}
.cartList ul li input[name="minus"],.cartList ul li input[name="plus"]{height: 25px;border: 1px #999999 solid;width: 25px;text-align: center;
}
.cartList ul li:nth-of-type(1){width: 130px;}
.cartList ul li:nth-of-type(2){width: 100px;}
.cartList ul li:nth-of-type(3){width: 130px;}
.cartList ul li p{cursor: pointer;}
.cartList ol{float: right;clear: both;margin-top: 40px;
}
.cartList ol li{float: left;
}
.cartList ol li:nth-of-type(1){color: #ff0000;width: 80px;height: 35px;line-height: 35px;text-align: center;
}
.cartList ol li span{display: inline-block;float: right;width: 80px;height: 35px;line-height: 35px;font-size: 14px;font-family: "微软雅黑";background: #ff0000;color: #ffffff;text-align: center;/*margin-top: 5px;*//*margin-right: 15px;*/cursor: pointer;font-weight: bold;}</style>
</head><!--onload,在加载时计算好原始金额-->
<body onload="total()"><div class="content"><div class="logo"><span ><a href="购买精选.html#gouwu" style="color: white;text-decoration: none;">关闭</a></span></div><div class="cartList"><ul><a name="gouwuche"><li>商品信息</li></a><li>商品图片</li><li>单价(元)</li><li>数量</li><li>金额(元)</li><li>操作</li></ul><ul style="display: flex;justify-content: space-between;align-items: center" id="first"><li>Nike/耐克AIR JORDAN 1 男女AJ1薄荷绿</li><li><img src="data:images/xie2.jpg" alt="" width="50" height="50"></li><li>¥<input type="text" name="price" value="2799"></li><li><input type="button" name="minus" value="-" onclick="minus(0)"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(0)" ></li><li id="price0">¥2799</li><li><p onclick="save()">移入收藏</p><p onclick="delete1()">删除</p></li></ul><ul style="display: flex;justify-content: space-between;align-items: center; margin: 20px 0;"><li>Nike耐克官方AIR MAX 270 REACT女子运动鞋</li><li><img src="data:images/xie7.jpg" alt="" width="50" height="50"></li><li>¥<input type="text" name="price" value="1039"></li><li><input type="button" name="minus" value="-" onclick="minus(1)"><input type="text" name="amount" value="2"><input type="button" name="plus" value="+" onclick="plus(1)"></li><li id="price1">¥1039</li><li><p onclick="save()">移入收藏</p><p onclick="delete1()">删除</p></li></ul>
<ul style="display: flex;justify-content: space-between;align-items: center; margin: 20px 0;"><li>李宁羽毛球鞋女鞋防滑女士鞋子低帮运动鞋</li><li><img src="data:images/xie11.jpg" alt="" width="50" height="50"></li><li>¥<input type="text" name="price" value="228"></li><li><input type="button" name="minus" value="-" onclick="minus(2)"><input type="text" name="amount" value="3"><input type="button" name="plus" value="+" onclick="plus(2)"></li><li id="price2">¥228</li><li><p onclick="save()">移入收藏</p><p onclick="delete1()">删除</p></li></ul><ul style="display: flex;justify-content: space-between;align-items: center; margin: 20px 0;"><li>PUMA彪马官方正品 刘雯同款新款女子复古休闲鞋</li><li><img src="data:images/xie15.jpg" alt="" width="50" height="50"></li><li>¥<input type="text" name="price" value="809"></li><li><input type="button" name="minus" value="-" onclick="minus(3)"><input type="text" name="amount" value="4"><input type="button" name="plus" value="+" onclick="plus(3)"></li><li id="price3">¥809</li><li><p onclick="save()">移入收藏</p><p onclick="delete1()">删除</p></li></ul><ul style="display: flex;justify-content: space-between;align-items: center; margin: 20px 0;"><li>【燃冬季】Vans范斯官方灰色Vans解构小香风男女</li><li><img src="data:images/xie19.jpg" alt="" width="50" height="50"></li><li>¥<input type="text" name="price" value="465"></li><li><input type="button" name="minus" value="-" onclick="minus(4)"><input type="text" name="amount" value="5"><input type="button" name="plus" value="+" onclick="plus(4)"></li><li id="price4">¥465</li><li><p onclick="save()">移入收藏</p><p onclick="delete1()">删除</p></li></ul><ol><li id="totalPrice">&nbsp;</li><li><span>结算</span></li></ol></div>
</div>
</body>
</html><script>//减法function minus(index) {//获取当前数量的值var amounts=document.getElementsByName("amount");//得到第一个amount的元素的value属性的值var count=parseInt(amounts[index].value); //数量加1if (count<=1){alert("不能再减了,快没了!!");} else {//得到第一个amount的元素的value属性的值var count=parseInt(amounts[index].value)-1; //数量加1//重新把count的值绑定在数量文本框里amounts[index].value=count;var prices=document.getElementsByName("price");var price=parseFloat(prices[index].value);//乘以Math.pow(10,2)的原因为避免失真var totalMoney=((price*Math.pow(10,2))*count)/Math.pow(10,2);document.getElementById("price"+index).innerHTML="¥:"+totalMoney;}total();}//加法function plus(index) {//获取当前数量的值var amounts=document.getElementsByName("amount");//得到第一个amount的元素的value属性的值var count=parseInt(amounts[index].value)+1; //数量加1//重新把count的值绑定在数量文本框里amounts[index].value=count;//当前操作端口的价格也要重新计算//得到当前端口的单价var prices=document.getElementsByName("price");var price=parseFloat(prices[index].value);//乘以Math.pow(10,2)的原因为避免失真var totalMoney=((price*Math.pow(10,2))*count)/Math.pow(10,2);//把当前价格显示在文本中document.getElementById("price"+index).innerHTML="¥:"+totalMoney;total();}//求总金额function total() {//得到所有的数量var counts=document.getElementsByName("amount");//得到所有的单价var prices=document.getElementsByName("price");var sumMoney=0;for (var i=0;i<counts.length;i++){//乘以Math.pow(10,2)的原因为避免失真sumMoney+=(parseFloat(prices[i].value)*Math.pow(10,2)*parseInt(counts[i].value)/Math.pow(10,2));}//把总金额显示再指定的元素中document.getElementById("totalPrice").innerHTML="¥:"+sumMoney;}//加入收藏function save() {if (confirm("确认要收藏吗?")){alert("收藏成功!");}}//删除function delete1() {if (confirm("确认要删除吗?")) {var del=document.getElementById("first");del.parentNode.removeChild(del);alert("删除成功!!");}}
</script>

潮鞋购物网站,html5+css3+js,实现基本的添加购物车,自动计算金额等功能相关推荐

  1. ❤生日快乐网站模板HTML❤(精品制作)(HTML5+CSS3+JS)

    生日快乐网站模板HTML(精品制作)(HTML5+CSS3+JS) 最近姐姐的生日快到了,想着也没有什么礼物送给她,恰好因为CTF的原因学了点HTML和JavaScript,就做了两个网页,当然因为网 ...

  2. HTML5,CSS3,js

    HTML5,CSS3,js html5 html基本结构 块级标签和行级标签 html5表格 html5表单 css3 css使用方法 css常用属性 css3的过渡和变换 css3的动画属性和多列属 ...

  3. HTML生日快乐代码 (粉色主题)(HTML5+CSS3+JS)520表白代码/七夕情人节网页/告白/求婚/生日快乐

    html+css+js 生日快乐网站模板(多页面功能版本+音乐)❤520/表白/七夕情人节/求婚❤专用炫酷动画网页的源代码(HTML5+CSS3+JS) 程序员爱情❤520/表白/七夕情人节/求婚❤专 ...

  4. HTML生日快乐代码 (粉色主题)(HTML5+CSS3+JS)520表白代码/七夕情人节网页/告白/求婚/生日快乐...

    html+css+js 生日快乐网站模板(多页面功能版本+音乐)❤520/表白/七夕情人节/求婚❤专用炫酷动画网页的源代码(HTML5+CSS3+JS) 程序员爱情❤520/表白/七夕情人节/求婚❤专 ...

  5. 七夕静态页面html,html5+CSS3+JS实现七夕言情功能代码

    因为今天8月28日就是中国的情人节-七夕,作为程序猿一枚的我就只有在家敲代码咯!但我还是有一颗脱单的心:制作了h5+css+js界面祝小伙伴们:七夕快乐 具体的功能有: 1.下雪的背景动画 2.下面的 ...

  6. 2023年最全前端面试题考点HTML5+CSS3+JS

    合集:2023年最全前端面试题考点HTML5+CSS3+JS+Vue3+React18+八股文+手写+项目+笔试_参宿7的博客-CSDN博客 本章内容为一面基础面 为了简洁,相关文章参考链接在标题里 ...

  7. 利用HTML5+CSS3+JS实现简单的钟表

    HTML5+CSS3+JS实现动态时钟 利用HTML5+CSS3+JS实现简单的钟表,仅供参考学习 效果图: 在线效果预览 思路: 1. 先定义一个类名为timepiece的圆表表盘 HTML: &l ...

  8. Web端点餐系统(HTML5 + CSS3 + JS(jQuery))

    Web点餐系统(前端开发) 一.系统简介 二.系统设计 三.系统实现 · 首页(当天菜品)/推荐菜品/热买菜品 · 已选菜品 · 我的订单 · 订单统计 四.总结 五.源码下载 一.系统简介 该Web ...

  9. HTML5 + css3 + js 网页设计作业 网页小游戏

    用HTML5 + css3 + js 做的一个翻图片的网页小游戏,挺有意思的吧! 因为上网页课要交一个个人的网页设计作业,时间挺紧的,记得以前玩游戏偶尔看到一个翻转图片的小游戏,就想模仿着做一个! 目 ...

  10. js php通讯录,基于aotu.js实现微信自动添加通讯录中的联系人功能

    什么是Auto.JS? Auto.JS是Android平台上的JavaScript自动化工具. 它的本质是可执行自己编写的简易Javascript脚本的,尤其可以在开启"无障碍模式" ...

最新文章

  1. 【论文速读】基于图像的伪激光雷达三维目标检测
  2. 利用OpenCV 基于Inception模型图像分类
  3. html渐变色CSS3 渐变,如何实现css3渐变色,css3渐变色怎么写
  4. leetcode- 两数之和
  5. php grid 分页,jqGrid实现前端分页
  6. MyBatis全局配置文件介绍
  7. 《子弹笔记术》[日]杉野干人(作者)epub+mobi+azw3格式下载
  8. Chrome无法打开文件的错误 [Not allowed to load local resource: file://XXXX]
  9. 全方位解析阿里云核心技术竞争力,CSDN 独家在线峰会来了!
  10. iOS中UINavigationController控制器使用详解
  11. 多标签分类任务大赛50万奖金等你来
  12. HDU 3729【二分匹配】
  13. 服务器发送 微信通知,方糖,使用微信通知的小接口
  14. Python 编码检测与编码转换
  15. IMO2019 D1T1解答
  16. java work stealing_工作窃取(work-stealing)算法
  17. Java——文本框设置背景颜色、字体样式和颜色
  18. 【软件定义汽车】【场景篇】AR-HUD
  19. WPS整段缩进(类似代码格式)
  20. 苦于抖音四季文案久已的朋友们快看过来!

热门文章

  1. 找回童年乐趣,在线玩超级玛丽、冒险岛、魂斗罗、坦克大战等经典游戏
  2. 我把 Python 协程的本质扒得干干净净
  3. 中通科技代码覆盖率应用实践(二)
  4. AnyShare 6.0.10实施部署(ESwift)
  5. mysql concat 日期_MySQL tips (日期时间操作/concat 等)
  6. 摒弃单一变现手段,开拓多元商业模式,破解场景单一APP盈利难题!
  7. 2022化工自动化控制仪表考试题库及模拟考试
  8. Meta 分析在生态环境领域、Biome-BGC生态系统模型区域模拟
  9. Leetcode 538. 把二叉搜索树转换为累加树 C++
  10. Labview2019,通讯三菱plc,用opc和mc通讯协议,sqlite数据库,labview标准框架jki状态机,加上数组队列,实现多线程交互。