Skip to content

Commit fe05cf3

Browse files
authored
Create index.html
1 parent 3b47cf7 commit fe05cf3

File tree

1 file changed

+17
-0
lines changed
  • JavaScript之将数字字符转换为数字以参与数学运算-渐进HTML7

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>将数字字符转化为数字以参与数学运算</title>
6+
</head>
7+
<body>
8+
<script>
9+
var price = "123.5";
10+
var num = "8";
11+
var amount;
12+
13+
amount = parseFloat(price) * parseInt(num);
14+
window.alert("您购买的商品单价为" + price + "元,您将有购买" + num + "个,金额为" + amount + "元。");
15+
</script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)