Jquery Event
Advertisements
Event
Event are occurred when something happens on web page. Some example of events are;
- moving a mouse over an element
- Click mouse over an element
- selecting a radio button
- clicking on an element
Syntax
$("p").click();
Next you must be defined what should happen when the event fires. You must pass a function to the event:
Syntax
$("p").click(function(){ // action perform });
Example of Event in jQuery
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $(".para").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>Click on below text, I will disappear.</p> <p class="para">Click me please!</p> <p class="para">Click me too!</p> </body> </html>
Output
Click on below text, I will disappear.
Click me please!
Click me too!
Common DOM Events
Mouse Events | Keyboard Events | Form Events | Document/Window Events |
---|---|---|---|
click | keypress | submit | load |
dblclick | keydown | change | resize |
mouseenter | keyup | focus | scroll |
mouseleave | blur | unload |
Google Advertisment