Opened 11 years ago
Closed 11 years ago
#10777 closed bug (invalid)
.toggleClass( className, switch ) works incorectly with non-bool type 'switch' argument
Reported by: | San4es | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When you use non-bool "switch" argument .toggleClass works incorrectly in some cases:
.toggleClass(className, true) != .toggleClass(className, 1) .toggleClass(className, 0) != .toggleClass(className, false)
I consider that this function should work as stated in the documentation, as
if (addOrRemove) { $('#foo').addClass(className); else $('#foo').removeClass(className);
I tests all version of jquery.
Examples here: http://jsfiddle.net/f2NU3/
Note: See
TracTickets for help on using
tickets.
Quote from the documentation,
There is a jQuery UI extension that accepts a number as its second parameter.
http://jqueryui.com/demos/toggleClass/