jQuery购物车提醒问题
发布网友
发布时间:2022-09-23 12:13
我来回答
共1个回答
热心网友
时间:2024-10-04 09:59
<script>
jQuery(function($) {
$("#add").on("click", function() {
var boxs = $(":checkbox[name='haitai']:checked");
if (!boxs.length) {
alert("请选择商品!");
} else {
var bao = "";
boxs.each(function(i, dom) {
bao += $(dom).attr("value") + "\n";
});
localStorage.car = localStorage.car ? bao + localStorage.car : bao;
alert("成功加入购物车!");
}
});
});
</script>