Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> </head> <body> 姓: <input type="text" id="myText" value="Mickey"><br> <button onclick="disableTxt()">禁用文本域</button> <button onclick="undisableTxt()">启用文本域</button> <script> function disableTxt() { document.getElementById("myText").disabled = true; } function undisableTxt() { document.getElementById("myText").disabled = false; } </script> </body> </html>