jquery core: Closes #1681. jQuery.fn.toggleClass can accept a boolean argument indicating add/remove.
This commit is contained in:
parent
0e3e470edc
commit
0a8f96ac3d
2 changed files with 12 additions and 3 deletions
|
@ -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 ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue