JavaScript DOM操作案例点击按钮禁用文本框
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <input type="button" value="禁用文本框" id="bt"/> <input type="text" value="我是文本框" id="tex"/> <script> document.getElementById("bt").onclick = function () { document.getElementById("tex").disabled = "disabled"; }; </script> </body> </html>