Modify ↓
Ticket #8097 (closed feature: wontfix)
replaceClass
| Reported by: | rudeboiidevil2k7@… | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | attributes | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
jQuery should include a function that replace a class, for example if you wish to replace a class you could do it like this:
$('#element').replaceClass('classname', 'tothisclassname');
Instead of doing something like this:
Would be easier to have this feature, don't you think? :)
$('#element').removeClass('classname');
$('#element').addClass('tothisclassname');
Change History
comment:2 Changed 2 years ago by addyosmani
- Status changed from new to closed
- Resolution set to wontfix
As mentioned above (and can be seen here), toggleClass's syntax supports easily switching classes (or replacing as you refer to it) already. Unless there are use-cases which toggleClass would not be appropriate for, we'll be closing this feature/enhancement request as the behavior is already supported.
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.

You can actually use toggleClass in this fashion as shown here: http://jsfiddle.net/mv6mB/
http://api.jquery.com/toggleClass/