aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAriel Flesler <aflesler@gmail.com>2008-12-25 20:12:18 +0000
committerAriel Flesler <aflesler@gmail.com>2008-12-25 20:12:18 +0000
commit0a8f96ac3d37f637ab433c037d4f807e8ef94bbe (patch)
treec1e43b5915ca26a83d00819dcbe1cdc259612697 /src
parent0e3e470edc77cde0eede8aa6b7642c336d081d66 (diff)
downloadjquery-0a8f96ac3d37f637ab433c037d4f807e8ef94bbe.tar.gz
jquery-0a8f96ac3d37f637ab433c037d4f807e8ef94bbe.zip
jquery core: Closes #1681. jQuery.fn.toggleClass can accept a boolean argument indicating add/remove.
Diffstat (limited to 'src')
-rw-r--r--src/core.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core.js b/src/core.js
index 0e02436fc..5a098bebd 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1284,8 +1284,10 @@ jQuery.each({
jQuery.className.remove( this, classNames );
},
- toggleClass: function( classNames ) {
- jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
+ toggleClass: function( classNames, state ) {
+ if( typeof state !== "boolean" )
+ state = !jQuery.className.has( this, classNames );
+ jQuery.className[ state ? "add" : "remove" ]( this, classNames );
},
remove: function( selector ) {