#8097 closed feature (wontfix)
replaceClass
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | attributes | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
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 (4)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
comment:3 Changed 13 years ago by
Component: | unfiled → attributes |
---|---|
Priority: | undecided → low |
comment:4 Changed 13 years ago by
Also, jQueryUI's toggleClass adds animation support incase you're itching to make that feature request.
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/