See the mall inside, you can add to reduce the number of shopping, just want to learn
The code is as follows:
<! DOCTYPE html>
<meta charset= "Utf-8"/>
<TITLE>JS Click to add 1 implementation </title>
<style type= "Text/css" >
. jia{height:16px;width:auto;text-align:center;display:inline-block;padding:5px;border:1px solid #ccc; cursor: pointer;}
. jian{height:16px;width:auto;text-align:center;display:inline-block;padding:5px;border:1px solid #ccc; cursor: pointer;}
</style>
<script type= "Text/javascript" >
Window.onload = function ()
{
var Jjian = document.getElementById ("Jian");
var Jjia = document.getElementById ("Jia");
var ZJ = document.getelementsbytagname ("input") [0];
var i = 1;
Jjia.onclick = function ()
{
Zj.value = ++i;
i = Zj.value;
Zj.value = ++i;
}
Jjian.onclick = function ()
{
i = Zj.value;
Zj.value =-I.;
}
}
</script>
<body>
<div id= "Put" >
<span class= "Jian" id= "Jian" >-</span>
<input type= "Text" value= "1" style= "width:50px;text-align:center;height:22px;"/>
<span class= "Jia" id= "Jia" >+</span>
</div>
</body>
JS Learning-Shopping Quantity +1,-1