编辑下面的代码:【加编码】
<html> <body> 输入您的名字: <input type="text" id="fname" onfocusout="myFunction()"> <p>当你离开 input 输入框时,JavaScript函数将被触发,并将输入框中的小写字母转为大写。</p> <p><strong>注意:</strong> Firefox 浏览器不支持 onfocusout 事件。</p> <script> function myFunction() { var x = document.getElementById("fname"); x.value = x.value.toUpperCase(); } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂