jQuery Tutorials
jQuery Effects
jQuery HTML
jQuery Traversing
jQuery AJAX
jQuery Misc
JQuery is well-designed to respond to events on an HTML page.
All the actions of different visitors that the web page can respond to are called events.
An event represents the exact time when something happens.
Examples
The word "fires / fire" is often used with events. Example: "A key press event is off, when you press a key".
Here are some 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 |
In jQuery, most DOM events have the same jQuery method.
To provide a click-through event for all categories on the page, you can:
The next step is to define what should happen when an event is burning. You must transfer work to the event:
$(document).ready()
The $(document).ready()
method allows us to do the job once the document is fully loaded. This event has already been described in the jQuery Syntax chapter.
click()
The click()
method pastes the event host function into the HTML component.
Task is performed when the user clicks on the HTML object.
The following example is: If a click event burns in the <p> element; hide <p> current section:
dblclick()
The dblclick()
method attaches the event host function to the HTML component.
Task performed when user double-clicks HTML object:
mouseenter()
The mouseenter()
method attaches an event host function to the HTML component.
Task performed when mouse cursor enters HTML object:
mouseleave()
The mouseleave()
method attaches the event host function to the HTML component.
Task performed when mouse cursor leaves HTML element:
mousedown()
Mousedown()
method attaches the event host function to the HTML component.
The function is performed, when the left, middle or right mouse button is pressed down, while the mouse over the HTML element:
mouseup()
The mouseup()
method attaches an event handler function to an HTML element.
The function is executed, when the left, middle or right mouse button is released, while the mouse is over the HTML element:
hover()
The hover()
method takes two functions and is a combination of mouseenter ()
and mouseleave()
methods.
The first function is performed when the mouse enters the HTML component, and the second function is performed when the mouse leaves the HTML element:
focus()
The focus()
method attaches an event host function to an HTML form.
Work is done when the form field focuses on:
blur()
The blur()
method attaches the event host function to the HTML form.
Work performed when form field loses focus:
The on()
method attaches one or more event holders to selected elements.
Paste a click-through event in the <p> section:
Attach multiple event handlers to the <p> section: