???? ??? ?? ??? ?????? ??
??? ?? ?? ??
html ??? ??:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>購(gòu)物車(chē)加減</title> <style type="text/css"> a{ text-decoration: none;display:block;width:30px;height:30px; background:#eee;line-height:30px;font-weight:bolder; } .body{width:500px;height:300px;background:#ccc;margin:0 auto;text-align:center;padding:80px;} #a1{float:left;margin-right:20px;margin-top:2px;text-align:center;} form{float:left;} form input{width:40px;height:30px;border:1px solid #eee;text-align:center;} #a2{float:left;margin-left:20px;margin-top:2px;text-align:center;} </style> </head> <body> <div> <a href="#" id="a1">-</a> <form> <input type= "text" value="1" id='id'> </form> <a href="#" id="a2">+</a> </div> </body> </html>
?? ??? ?? ?, ? 1
var input = document.getElementById('id').value;? ???? ???.
??? ???
?? ??? ???? ??? ??? ????.
????????????????????????????????????????????????????? document.getElementBy ID('a1').??????????????????????????????????????????????????????????????? Alert( "??? ?????") - 1;
?????????????~ ~??????????????????????????????????????????alert("??? ?????"); v1 = document.getElementById('id').value;????????????????????????????????????????????????????~?????????????(id) || {
?8???????????????????????????????????????????????????????????????????????????????????????????????