编辑下面的代码:【加编码】
<html> <body> 姓名: <input type="text" id="myText"> <p>点击按钮设置文本域允许输入的最大的字符数。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myText").maxLength = "4"; document.getElementById("demo").innerHTML = "现在文本域允许最大的最大字符数为 4。"; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂