Skip to main content

Bug Tracker

Side navigation

#8097 closed feature (wontfix)

Opened January 31, 2011 02:00PM UTC

Closed January 31, 2011 03:38PM UTC

Last modified January 31, 2011 04:30PM UTC

replaceClass

Reported by: rudeboiidevil2k7@hotmail.co.uk 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');
Attachments (0)
Change History (4)

Changed January 31, 2011 02:52PM UTC by Alexis Abril comment:1

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

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

Changed January 31, 2011 03:38PM UTC by addyosmani comment:2

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.

Changed January 31, 2011 03:50PM UTC by jitter comment:3

component: unfiledattributes
priority: undecidedlow

Changed January 31, 2011 04:30PM UTC by danheberden comment:4

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