内容比较少,直接看代码吧。这里没有后台
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<style>
.box{
width:150px;
height:50px;
position:absolute;
left:47%;
top:50px;
}
#text{
width:50px;
text-align:center;
}
</style>
<body>
<script type="text/javascript" src="/Shop/js/jquery-3.3.1.js"></script>
<script>
$(function(){
var t = $("#text");
$("#add").click(function(){
t.val(parseInt(t.val())+1)
})
$("#min").click(function(){
var x=parseInt(t.val());
if(x>1){
t.val(x-1);
}
else
t.val(1);
})
})
</script>
</head>
<body>
<div class="box">
<input id="min" name="" type="button" value="-" />
<input id="text" readonly="readonly" name="" type="text" value="3" />
<input id="add" name="" type="button" value="+" />
</div>
</body>
</html>