As the name suggests, the Keyboard Events are executed when we type something using the keyboard.
Let us see the important keyboard events provided by JQuery.
<html> <head> <title> My First Programme </title> </head> <body> <h1> JQuery </h1> Type Something : <input type = "text"> <script src = "https://cdnjs.cloudflare.com/ajax/libs/JQUERY/3.3.1/jquery.min.js"> </script> <script> $('input').keydown( function() { $(this).css("background-color", "yellow") }); </script> </body> </html>
<input type = "text">
$('input').keydown( function() { $(this).css("background-color", "yellow") });
$('input')
$('input').keydown(...)
$('input').keydown( function() { $(this).css("background-color", "yellow") });
function() { $(this).css("background-color", "yellow") });
<html> <head> <title> My First Programme </title> </head> <body> <h1> JQuery </h1> Type Something : <input type = "text"> <script src = "https://cdnjs.cloudflare.com/ajax/libs/JQUERY/3.3.1/jquery.min.js"> </script> <script> $('input').keyup( function() { $(this).css("background-color", "red") }); </script> </body> </html>
<input type = "text">
$('input').keyup( function() { $(this).css("background-color", "red") });
$('input')
$('input').keyup(...)
$('input').keyup( function() { $(this).css("background-color", "red") });
function() { $(this).css("background-color", "red") });
<html> <head> <title> My First Programme </title> </head> <body> <h1> JQuery </h1> Type Something : <input type = "text"> <script src = "https://cdnjs.cloudflare.com/ajax/libs/JQUERY/3.3.1/jquery.min.js"> </script> <script> $('input').keypress( function() { $(this).css("background-color", "blue") }); </script> </body> </html>
<input type = "text">
$('input').keypress( function() { $(this).css("background-color", "blue") });
$('input')
$('input').keypress(...)
$('input').keypress( function() { $(this).css("background-color", "blue") });
function() { $(this).css("background-color", "blue") });
<html> <head> <title> My First Programme </title> </head> <body> <h1> JQuery </h1> Type Something : <input type = "text"> <script src = "https://cdnjs.cloudflare.com/ajax/libs/JQUERY/3.3.1/jquery.min.js"> </script> <script> $('input').keyup( function() { $(this).css("background-color", "red") }); $('input').keydown( function() { $(this).css("background-color", "yellow") }); </script> </body> </html>
<input type = "text">
$('input').keydown( function() { $(this).css("background-color", "yellow") });
$('input').keyup( function() { $(this).css("background-color", "red") });