HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
jQuery Event Methods : Toggle between colors when clicking on a <p> element
The toggle() method attaches two or more functions to toggle between for the click event for the selected elements.
When clicking on an element, the first specified function fires, when clicking again, the second function fires, and so on.
Note: There is also a jQuery Effects method called toggle(). Which one is called, depends on the parameters.
Parameter | Description |
---|---|
function | Required. A function to run every time the selected element is clicked |