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 ) {
});
test("toggleClass(String)", function() {
- expect(3);
+ expect(6);\r
var e = jQuery("#firstp");
ok( !e.is(".test"), "Assert class not present" );
e.toggleClass("test");
ok( e.is(".test"), "Assert class present" );
e.toggleClass("test");
ok( !e.is(".test"), "Assert class not present" );
+
+ e.toggleClass("test", false);\r
+ ok( !e.is(".test"), "Assert class not present" );\r
+ e.toggleClass("test", true);\r
+ ok( e.is(".test"), "Assert class present" );\r
+ e.toggleClass("test", false);\r
+ ok( !e.is(".test"), "Assert class not present" );\r
});
test("removeAttr(String", function() {