运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript HTML Events</h1> <h2>The onkeyup Attribute</h2> <p>A function is triggered when the user releases a key in the input field.</p> <p>The function transforms the input character to upper case.</p> Enter your name: <input type="text" id="fname" onkeyup="myFunction()"> <script> function myFunction() { const x = document.getElementById("fname"); x.value = x.value.toUpperCase(); } </script> </body> </html>