jQuery events are the actions that can be detected by your web application. They are used to create dynamic web pages. An event shows the exact moment when something happens.
These are some examples of events.
- A mouse click
- An HTML form submission
- A web page loading
- A keystroke on the keyboard
- Scrolling of the web page etc.
These events can be categorized on the basis their types:
Mouse Events
- click
- dblclick
- mouseenter
- mouseleave
Keyboard Events
- keyup
- keydown
- keypress
Form Events
- submit
- change
- blur
- focus
Document/Window Events
- load
- unload
- scroll
- resize
Note: A term “fires” is generally used with events. For example: The click event fires in the moment you press a key.
Syntax for event methods
Most of the DOM events have an equivalent jQuery method. To assign a click events to all paragraph on a page, do this:
$("p").click ();
The next step defines what should happen when the event fires. You must pass a function to the event.
- $("p").click(function(){
- // action goes here!!
- });
Leave a Reply