- To make a page dynamic and responsive, we need to perform some actions on the HTML DOM elements.
- These actions are called events.
- Some examples of events are listed below:
- A mouse click
- Form submission
- Loading a web page
- Web page scrolling
- Pressing a key on the keyboard
- Mouse hover on an element
Some most useful HTML DOM events are listed below:
1 Mouse events:
2 keyboard events:
3 form events:
4 Document/Window Events:
The syntax for events in jQuery:
In the jQuery library, there is an equal range of methods for most of the DOM events.
For example: if you want to assign a click event on a button, the syntax is like:
The next step defines what should happen when the event fires. You must pass a function to the event.
// action goes here!!
<h2>jQuery events Example</h2>
<button class="bt">Click me to change the color of background</button>
After, click on the button,
Waiting for your comments