and when dealing with multiple classes on the same element, I've found it
necessary at times to use:

.attr('class' , 'class-name1 class-name2')

where .class-name1 typically doesn't change, but .class-name2 might be any
one of 5 or 6 different classes. Rather than trying to figure out which one
of the 5 I need to remove, I just set the class to the combination I want.
If that makes any sense... 

rolf 



Karl Swedberg-2 wrote:
> 
> 
> I can't build the whole thing for you because I don't know what is  
> being clicked and which element's class you want changed, but in  
> general you can manipulate classes with .addClass('some-class')  
> and .removeClass('optional-class-name') and .toggleClass('some-class').
> 
> You'll find these methods (and more!) here:
> http://docs.jquery.com/Attributes/
> 
> --Karl
> _________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
> 
> 
> 
> On Jan 25, 2008, at 12:23 PM, vanoosterhout wrote:
> 
>>
>> I know this may be a pretty elementary question, but I am trying to
>> figure out how to change a class based on a click.  I think should be
>> able to do this with replaceWith, but for some reason I am struggling.
>>
>> I have this:
>>
>> <li id="st1" class="current">1.Boat Select</li>
>> <li id="st2" class="">2.Halyard Length</li>
>> <li id="st3">3.Shackle Select</li>
>>
>> and for example would like to change it to:
>>
>> <li id="st1" class="done">1.Boat Select</li>
>> <li id="st2" class="current">2.Halyard Length</li>
>> <li id="st3">3.Shackle Select</li>
>>
>>
>> Basically I want to be able to change the class ... and nothing else.
>> If anyone could provide a snippet of sample code I would be very
>> thankful.
>>
>> Thanks,
>>
>> Christopher
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/replaceWith----Use-with-Classes-tp15093364s27240p15095040.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to