View Full Version : functions don't work, need help changing things

06-01-2005, 04:59 AM
Hi everyone. I've written a small function to change the background color of an anchor. It changes when somebody clicks on it from a list of FAQs.

I added a line to try to change back to white when somebody clicks on another one so that only the one most recently clicked on is highlighted.

Also, anytime I try to put something in a function, it stops working. Any ideas?

var aneo;
function setbg(aneo)
return 0;

<a href="#cash" onClick="javascript:setbg('cash');">...</a>

Any suggestions? Thanks!

06-01-2005, 06:15 AM
getElementsByTagName() returns an array of all the tags on your page. So you would need to do something like this instead;

var links = document.getElementsByTagName("A");
for (i=0; i<links.length; i++) {
links[i].style.backgroundColor = "white";