Events Examples

All Javascript code and CSS code are inserted at the top of the page. Below are all HTML markup being modified via jQuery.

Use of toggleClass()


Use of hover()


Custom events (use of bind() and trigger())





Use of event.target

Clicking on the buttons won't hide them, but clicking out here will!

Use of event.stopPropagation()

Notice how clicking a button won't activate the 'you clicked the div' alert.

Event delegation


Event namespacing

Click me and I will greet you.