jQuery keyup() Event
jQuery keyup event triggers when a key is released its pressing from the selected element.
Syntax of Keyup Event
$(selector).keyup(function)
The selector is the element on which keyup event trigger. The function is an optional parameter. This function is called when the keyboard button is released from the keyboard.
Example
<form>
<input type="text" value="Enter Text" id="keyup" />
</form>
<script>
$(document).ready(function(){
$("#keyup").keyup(function(){
alert("The keyup event occurs.");
});
});
</script>
Output of the above code
In the above example, an alert message is displayed when the user released key from the input box.
Example
<form>
<textarea id="keyprstxt" /></textarea>
</form>
<script>
$(document).ready(function(){
$("#keyprstxt").keyup(function(){
$("#keyprstxt").css("background", "yellow");
});
});
</script>
Output of the above code
In the above example, the background color of the textarea is changed when the key is released from the input box.