<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script> window.onload = function(){ var oInp = document.getElementById("inp"); var oBtn = document.getElementById("btn"); oBtn.onclick = function(){ // oInp.value = "123123";//用点来实现 // oInp['value'] = "123213";//用中括号 里面是字符串 oInp.setAttribute('value',"123123"); } } </script> </head> <body> <input type="text" id="inp"/> <button id="btn">按钮</button> </body> </html>