.toggle()     **REMOVED** JQ Home  <<  Events  <<  .toggle()

Mouse toggle event handler.

Description

The .toggle() method is used to bind two or more event handlers to the matched set that are executed cyclically on mouse clicks.

  • The toggle event is exactly the same as binding the .click() event to the specified element when only one handler is specified.
  • Use the .click() method if you only want to handle a single click.
  • Use the .dblclick() method if you only want to handle timed double clicks.
  • There is also an animation method named .toggle() and the method that is fired depends on the set of arguments passed.

This method was deprecated in jQuery 1.8 and removed in jQuery 1.9 so we are just showing it for completeness.

Syntax

Signature Description
.toggle( handler1 (eventObject) [,handlerN (eventObject)] ) Bind two or more event handlers to the matched set that are executed on alternate mouse clicks.

Parameters

Parameter Description Type
handler1 (eventObject)A function to execute when the mouse pointer is clicked on the element the first time.
  • This is the same as binding the .click() event to the function when no other handlers are specified.
Function
handlerN (eventObject)A function to execute when the mouse pointer is clicked on the element the Nth time.Function

Return

A jQuery object.

Related Tutorials

jQuery Advanced Tutorials - Lesson 2 - Keyboard & Mouse Events