前提是先要把value中的值去掉
------解决方案--------------------
- HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>改变Input Value值</title> <script type="text/javascript"> function changeValue(){ var value = document.getElementById("inputID"); if(value.value!=""){ value.value="" } else{ value.value ="2"; } } </script> </head> <body> <div id="content"> <input type='text' name='name' id='inputID' value='1'> <input type='button' name='name' id='name' value='改变值' onclick = "changeValue()"> </div> </body> </html>