他の "Try it Yourself" の例が下にあります。
onkeyup 属性は、ユーザが(キーボードの)キー離したときに発火します。
チップ: onkeyup イベントに関連するイベントの順序:
イベント属性 | |||||
---|---|---|---|---|---|
onkeyup | Yes | Yes | Yes | Yes | Yes |
なし。
<element onkeyup="script">
値 | 説明 |
---|---|
script | script は onkeyup で実行される |
サポートする HTML タグ: | 次の要素を除くすべての HTML 要素: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
---|
"onkeyup" 属性と一緒に "onkeydown" を使用します: Using "onkeydown" together with the "onkeyup" attribute:
<input type="text" onkeydown="keydownFunction()" onkeyup="keyupFunction()">
Try it Yourself ❯
テキストフィールド内で離した実際のキーを出力します:
Enter your name: <input type="text" id="fname" onkeyup="myFunction()">
<script>
function myFunction() {
var x =
document.getElementById("fname").value;
document.getElementById("demo").innerHTML = x;
}
</script>
Try it Yourself ❯
HTML DOM リファレンス:onkeyup イベント