- 0133技术站
- 联系QQ:88526
- QQ交流群

- 微信公众号

定义和用法
onkeyup 属性在用户松开按键(在键盘上)时触发。
提示: 与 onkeyup 事件相关的事件触发顺序:
1、onkeydown
2、onkeypress
3、onkeyup
注意: onkeyup 属性不能使用于以下元素:<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, 或 <title>。
浏览器支持
所有主流浏览器都支持 onkeyup 事件属性
HTML 4.01 与 HTML5之间的差异
无。
语法
<element onkeyup="script">
属性值
值 | 描述 |
---|---|
script | 规定该onkeyup事件触发时执行的脚本。 |
当松开按键时运行脚本:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>0133技术站(0133.cn)</title> <script> function displayResult() { var x=document.getElementById("fname"); x.value=x.value.toUpperCase(); } </script> </head> <body> <p>在输入域松开按键时触发函数。该函数将小写字母转为大写字母。</p> 输入你的名字: <input type="text" id="fname" onkeyup="displayResult()"> </body> </html>
点击 "运行实例" 按钮查看在线实例
推荐手册