The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

highlight unhighlight link background?

Hi, I'm trying to create link that when a user clicks it, it will highlight the link with a bgcolor of blue, while when the user clicks on another link, the previous link will unhighlight and highlight the new link which was clicked.

For this snippets, its working on the highlighting part, but I've no idea how to get the unhighlighting work.
I've done lots of search on google but no luck. Hope someone could help me here. Thanks in advanced.

When highlight() is called it should assign a reference to the highlighted element to a global variable. When undohighlight() is called it will use the global variable to know which element to unhighlight.

WOW, what can I say. I've been dealing with this and searching high and low for explaination on this for approx 3 days and here, Mike save me with the final answer with one neat function! Thanks a million Mike! You're truly the man and I'll support Cross-Browser.com on my signature! Thanks again!

Is giving me the same 9 id everytime despite I choose link 2. I tried reading getElementsBySelector(), but no idea how to use it to reference the style in any way. Hope you can give some pointers here. Thanks.