.toggle()
In this chapter you will learn:
Syntax and Description
.toggle(handlerEven, handlerOdd[, additionalHandlers...])
handlerEven
is a function to execute every even time the element is clickedhandlerOdd
is function to execute every odd time the element is clickedadditionalHandlers (optional)
are additional handlers to cycle through after clicks
Return value is the jQuery object, for chaining purposes.
toggle
method binds two or more
handlers to the matched elements, to be executed on
alternate clicks.
For example:
<div id="target">
Click here
</div>
Event handlers can then be bound to the <div>.
$('#target').toggle(function() {
$.print('First ');
}, function() {
$.print('Second');
});
Next chapter...
What you will learn in the next chapter:
- Syntax and Description for .trigger() event
- How to trigger focus event
- How to trigger mouse over event
- How to trigger click event
- How to trigger the change event
- How to trigger a custom event