January 19, 2025
Events handling in jQuery
Events are certain actions on which we can perform some tasks. For example click is a event, mouse key down is an event, scroll is also an event etc. Whenever an even occurred we can perform certain task, for example on a button click we can trigger a http request. In jQuery also we have a set of events which we can use to perform tasks we need. Below we have list of events which are available in jQuery
blur() | focusin() | mousedown() | mouseup() |
change() | focusout() | mouseenter() | resize() |
click() | keydown() | mouseleave() | scroll() |
dblclick() | keypress() | mousemove() | select() |
error() | keyup() | mouseout() | submit() |
focus() | load() | mouseover() | unload() |
Example of click event
$("#buttonElement").click(function(){
alert("Perform some task on button click.");
});
Example of blur event
$("#inputTextElement").blur(function(){
alert("Perform some task on input box blur event.");
});
Example of change event
$("#selectElement").change(function(){
alert("Perform some task on select list's change event.");
});
Example of dblclick event
$("#buttonElement").dblclick(function(){
alert("Perform some task on button double click.");
});