HANDLING EVENTS

Handler and events

This page introduces the basic event handler concept.
The page shows also an example of usage of the is(), removeClass(), addClass() and toggleClass() functions.

Try to click on the next icon IMG NOT FOUND: this will fire the "clicked" event, which will be caught by the click() jQuery event handler.
The event handler takes care to switch between two CSS classes (.foo and .faa), creating the toggle-border effect.

The source embedded in this page shows also an example of usage of the is() function,
which takes as argument any DOM element or CSS selector, exactly as the basic jQuery function.

Remark: you may wonder why jQuery uses the dollar sign ($) as prefix.
The dollar sign is just a shortcut for writing (for example) jQuery('p'), since the latest is equivalent to $('p').
This is why we say that the "is() function takes the same argument of the basic jQuery function".

See the HTML source for details.

Sources

HOME