Modify ↓
Ticket #3638 (closed enhancement: duplicate)
Improve toggleClass
| Reported by: | soywiz | Owned by: | flesler |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.3 |
| Component: | unfiled | Version: | 1.2.6 |
| Keywords: | Cc: | soywiz | |
| Blocking: | Blocked by: |
Description
toggleClass: function( classNames, set ) {
if (set === undefined) set = jQuery.className.has( this, classNames ); jQuery.className[ set ? "add" : "remove" ]( this, classNames );
}
It will allow to do something like this, while mantaining the original behaviour:
$('#id').toggleClass('enabled', (var > 0));
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.

Duplicate of #1681.