diff options
author | Ariel Flesler <aflesler@gmail.com> | 2008-12-25 20:12:18 +0000 |
---|---|---|
committer | Ariel Flesler <aflesler@gmail.com> | 2008-12-25 20:12:18 +0000 |
commit | 0a8f96ac3d37f637ab433c037d4f807e8ef94bbe (patch) | |
tree | c1e43b5915ca26a83d00819dcbe1cdc259612697 /src | |
parent | 0e3e470edc77cde0eede8aa6b7642c336d081d66 (diff) | |
download | jquery-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.js | 6 |
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 ) { |