Hi.

On 14/03/2007, at 11:32, Bruce MacKay wrote:

> Hello folks,
>
> I'm seeking some help in changing the (in this case) background
> colour of links once they've been clicked.
>
> I have an application that contains many (50-100) links on a
> page.  Clicking on any one brings specific content into a  
> neighbouring div.
>
> What I want to do is to change the background colour of the most
> recently clicked link so that a user can see at a glance where they
> are in the list.
>
> This has two parts - the changing of the background colour of the
> current link to the highlight colour, and the change of the
> previously highlighted link back to the default.
>
> The first part I can do:
> $("#jqtree a").bind("click",function(){$(this).css 
> ("background","#CC004E")});
>
> I cannot do the second part. The previous and current links will not
> necessary be adjacent in the list and with so many links on the page,
> I'm wary of doing a global "set-to-default-colour" sweep of all links
> on the page before changing the colour of the most recently clicked  
> link.
>
> I'd appreciate directions to a better way.

You can modify the presentation of the link by modifying its class  
instead of aplying CSS rules on the fly.

$("#jqtree a").bind("click", function() {
        $("#jqtree a.someclass").removeClass("someclass");
        $(this).addClass("someclass");
});


HTH.
-- 
Choan Gálvez
<[EMAIL PROTECTED]>
<http://choangalvez.nom.es/>




_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to