.toggle()
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() {/*from ww w .j ava2s . com*/
$.print('Second');
});
Javascript Tutorial Event
Event
Event attributes
event.keycode
event.clientX/clientY
pageX/pageY
Cancel event
Event target
bind
.blur()
.change()
.click()
.error()
.dblclick()
.delegate()
.die()
.focus()
.hover()
.keydown()
.keypress()
.keyup()
.live()
.load()
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseover()
.mouseout()
.mouseup()
.off()
.on()
.one()
.ready()
.resize()
.scroll()
.select()
.submit()
.triggerHandler()
.unbind()
.undelegate()
.unload()
Event
Event attributes
event.keycode
event.clientX/clientY
pageX/pageY
Cancel event
Event target
bind
.blur()
.change()
.click()
.error()
.dblclick()
.delegate()
.die()
.focus()
.hover()
.keydown()
.keypress()
.keyup()
.live()
.load()
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseover()
.mouseout()
.mouseup()
.off()
.on()
.one()
.ready()
.resize()
.scroll()
.select()
.submit()
.toggle()
.trigger().triggerHandler()
.unbind()
.undelegate()
.unload()