That wil only toggle the class for the clicked element itself. You need to apply the changes to all of them. This is a bit redundant but is the shortest solution:
$(document).ready(function() { var $items = $(".accordion a"); $items.click(function(){ $items.removeClass('sel'); $(this).addClass('sel'); }); }); - ricardo On Oct 25, 4:05 pm, fotobob <[EMAIL PROTECTED]> wrote: > I'm new to jquery so be kind: > > My problem is this; > > I am trying to change the class of some links so that when I click on > one it becomes class "sel" (a particular background image), then when > I click on the next one, it becomes class "sel" and the previous one > returns to its before click state. > > According to the jquery site docs toggleClass should do it, but what I > get is all clicked links become class "sel" and none return to their > pre-clicked state: > > toggleClass( class ) Returns: jQuery > Adds the specified class if it is not present, removes the specified > class if it is present. > > Here's my code: > > $(document).ready(function() > { > $(".accordion a").click(function(){ > $(this).toggleClass("sel"); > }); > > }); > > What am I doing wrong? > > Thanks, > Bob