Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- jQuery Toggle


ChrisBolton - 10:26 pm on Jan 21, 2013 (gmt 0)


This should be an easy one, but I've been struggling with it for over two hours now. I would greatly appreciate any help with this.

I’ve got a number of identical buttons on a page, each with a number of identical classes. For example:

<a href="#" class="a b c"><span class="y">button</span></a>
<a href="#" class="a b c"><span class="y">button</span></a>
<a href="#" class="a b c"><span class="y">button</span></a>

I want to be able to swap the class 'c' for a new class 'e' when I click the anchor, but only on the button I click. I also want the class on the span element to toggle between the current class of 'y' and a new class of 'z' with the same click.

I’m sure I have done this before but it’s got me pulling my hair out right now. Can anyone help me please?

Thanks in advance.


Thread source:: http://www.webmasterworld.com/javascript/4538096.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com