Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#8097 closed feature (wontfix)

replaceClass

Reported by: rudeboiidevil2k7@… 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 Alexis Abril

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

http://api.jquery.com/toggleClass/

comment:2 Changed 13 years ago by addyosmani

Resolution: wontfix
Status: newclosed

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 jitter

Component: unfiledattributes
Priority: undecidedlow

comment:4 Changed 13 years ago by danheberden

Also, jQueryUI's toggleClass adds animation support incase you're itching to make that feature request.

Note: See TracTickets for help on using tickets.