Modify ↓
Ticket #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: | ||
| Blocking: | Blocked by: |
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/
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
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/