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="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>