|
@@ -1,5 +1,6 @@
|
|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
|
+
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
@@ -7,6 +8,7 @@
|
|
|
<title>Document</title>
|
|
|
<link rel="stylesheet" type="text/css" href="css/CartCss.css">
|
|
|
</head>
|
|
|
+
|
|
|
<body>
|
|
|
<form action="ShoppingCart.html" method="get">
|
|
|
<div class="Store">
|
|
@@ -34,8 +36,8 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
<div class="Store">
|
|
|
<a id="lable">
|
|
|
<input type="checkbox">
|
|
@@ -78,90 +80,76 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div id="BottomBar">
|
|
|
- <input type="submit" name="submit" value="Delete">
|
|
|
- <input type="submit" name="submit" value="Settle">
|
|
|
+ <input type="submit" name="submit" value="删除商品">
|
|
|
+ <input type="submit" name="submit" value="结算">
|
|
|
+
|
|
|
</div>
|
|
|
</form>
|
|
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
|
<script>
|
|
|
- $("form>div.Store>div.goods>div#exp>div#count>div").click(function()
|
|
|
- {
|
|
|
- if(this.innerHTML == "-")
|
|
|
- {
|
|
|
+ $("form>div.Store>div.goods>div#exp>div#count>div").click(function() {
|
|
|
+ if (this.innerHTML == "-") {
|
|
|
let text = $(this).next()[0];
|
|
|
let num = Number.parseInt(text.value);
|
|
|
// console.dir(num);
|
|
|
- if(num.toString() == "NaN") num = 0;
|
|
|
- else num = Math.max(0,--num);
|
|
|
+ if (num.toString() == "NaN") num = 0;
|
|
|
+ else num = Math.max(0, --num);
|
|
|
text.value = num;
|
|
|
- }
|
|
|
- else
|
|
|
- if(this.innerHTML == "+")
|
|
|
- {
|
|
|
+ } else
|
|
|
+ if (this.innerHTML == "+") {
|
|
|
let text = $(this).prev()[0];
|
|
|
let num = Number.parseInt(text.value);
|
|
|
// console.dir(num);
|
|
|
- if(num.toString() == "NaN") num = 1;
|
|
|
- else num = Math.max(0,++num);
|
|
|
+ if (num.toString() == "NaN") num = 1;
|
|
|
+ else num = Math.max(0, ++num);
|
|
|
text.value = num;
|
|
|
}
|
|
|
});
|
|
|
- $("form>div.Store>a#lable>input").change(function()
|
|
|
- {
|
|
|
+ $("form>div.Store>a#lable>input").change(function() {
|
|
|
let items = $(this).parent().parent().children("div.goods").children("input");
|
|
|
// console.dir(items);
|
|
|
- for(let i = 0; i < items.length; ++i)
|
|
|
- {
|
|
|
+ for (let i = 0; i < items.length; ++i) {
|
|
|
items[i].checked = this.checked;
|
|
|
}
|
|
|
});
|
|
|
- $("form>div.Store>div.goods>input").change(function()
|
|
|
- {
|
|
|
+ $("form>div.Store>div.goods>input").change(function() {
|
|
|
let lableChecker = $(this).parent().parent().children("a#lable").children("input");
|
|
|
- if(this.checked)
|
|
|
- {
|
|
|
+ if (this.checked) {
|
|
|
let otherGoods = $(this).parent().parent().children("div.goods").children("input").not(this);
|
|
|
- for(let i = 0; i < otherGoods.length; ++i)
|
|
|
- {
|
|
|
+ for (let i = 0; i < otherGoods.length; ++i) {
|
|
|
// console.dir(otherGoods[i].checked);
|
|
|
- if(!otherGoods[i].checked)
|
|
|
- {
|
|
|
+ if (!otherGoods[i].checked) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
lableChecker.prop("checked", true);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
lableChecker.prop("checked", false);
|
|
|
}
|
|
|
})
|
|
|
- $("form>div.Store>div.goods>div#exp>div#count>input").focusout(function()
|
|
|
- {
|
|
|
+ $("form>div.Store>div.goods>div#exp>div#count>input").focusout(function() {
|
|
|
let num = Number.parseInt(this.value);
|
|
|
- if(num.toString() == "NaN") num = 0;
|
|
|
+ if (num.toString() == "NaN") num = 0;
|
|
|
this.value = num;
|
|
|
- }).keyup(function()
|
|
|
- {
|
|
|
+ }).keyup(function() {
|
|
|
let num = Number.parseInt(this.value);
|
|
|
- if(num.toString() == "NaN") num = 0;
|
|
|
+ if (num.toString() == "NaN") num = 0;
|
|
|
this.value = num;
|
|
|
- }).keydown(function()
|
|
|
- {
|
|
|
+ }).keydown(function() {
|
|
|
let num = Number.parseInt(this.value);
|
|
|
- if(num.toString() == "NaN") num = 0;
|
|
|
+ if (num.toString() == "NaN") num = 0;
|
|
|
this.value = num;
|
|
|
});
|
|
|
- $("form>div#BottomBar>input[type='submit']").click(function()
|
|
|
- {
|
|
|
+ $("form>div#BottomBar>input[type='submit']").click(function() {
|
|
|
let counts = $("form>div#Store>div.goods>div#exp>div#count>input");
|
|
|
for (let index = 0; index < counts.length; index++) {
|
|
|
- let num = Number.parseInt( counts[index].value);
|
|
|
- if(num.toString() == "NaN") num = 0;
|
|
|
+ let num = Number.parseInt(counts[index].value);
|
|
|
+ if (num.toString() == "NaN") num = 0;
|
|
|
counts[index].value = num;
|
|
|
}
|
|
|
});
|
|
|
</script>
|
|
|
</body>
|
|
|
+
|
|
|
</html>
|