<html>
<head>
<script language="javascript">
function change(){
  bt1.value="111"
}
</script>
</head>
<body>
<form>
<input type="button" name="bt1" value="222" onClick="change()"/>
</form></body>
</html>我想单击按钮时改变按钮文字,为啥不行呢?

解决方案 »

  1.   

    <html>
    <head>
    <script language="javascript">
    function change(btn){
      btn.value="111"
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" name="bt1" value="222" onClick="change(this)"/>
    </form></body>
    </html>
      

  2.   

    <input type="button" name="bt1" value="222" onClick="change(this)"/>
    function change(bt1){
      bt1.value="111"
    }
      

  3.   

    <html>
    <head>
    <script language="javascript">
    function change(){
      document.getElementById("bt1").value="111"
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" id="bt1" value="222" onclick="change()"/>
    </form></body>
    </html>
      

  4.   

     bt1.value="111" 或改成
    document.getElementsByName("bt1")[0].value='111';
      

  5.   

    <html>
    <head>
    <script language="javascript">
    function change(){
      document.getElementById("bt1").value="111"
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" name="bt1" value="222" onClick="change()"/>
    </form></body>
    </html>
    Web 开发常用手册DHTML 参考手册
    http://download.csdn.net/source/308913JScript 语言参考
    http://download.csdn.net/source/308916CCS 样式表中文手册
    http://download.csdn.net/source/304124
      

  6.   

    <html>
    <head>
    <script language="javascript">
    function change(){
    var f = document.getElementsByTagName("form")[0]
      f.bt1.value="111"
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" name="bt1" id="bt1" value="222" onClick="change()"/>
    </form></body>
    </html>