利用Html+JavaScript实现简单购物车
程序员文章站
2024-03-20 13:25:34
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Shopping Car</title>
<script type="text/javascript">
function aa(){
document.getElementById("buy").value++;
}
function bb(){
x=document.getElementById("buy").value;
if(x>0)
document.getElementById("buy").value--;
}
</script>
</head>
<body>
<input type="button" value="-" onclick="bb()">
<input type="text" value="0" id="buy">
<input type="button" value="+" onclick="aa()">
</body>
</html>