Event handling is one of the core functions in jQuery. Event handlers are methods that are called when an action occurs in HTML. These actions are also referred to as event triggers.
When these events are triggered you can then use a function to perform some action with regard to the event. There are several events that we have access to in jQuery. Here are some generic examples of actions that can trigger an event:
- Clicking the mouseHovering over an elementLoading a pageSubmitting a formA keystroke
Let us take a look at a common example, where you may want to hide an element when the click event occurs.
In the previous above, a function is called when the click event for the div with an id of div1 is triggered: $("#div1").click(function() {..other code…} ). Here are some other jQuery events that you would commonly use in your web pages.