執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
轉到 Spaces
<!DOCTYPE html> <html> <body> <p>Assign an "onchange" event to an input element.</p> Enter your name: <input type="text" id="fname" onchange="myFunction()"> <p>When you leave the input field, a function is triggered which transforms the input text to upper case.</p> <script> function myFunction() { var x = document.getElementById("fname"); x.value = x.value.toUpperCase(); } </script> </body> </html>