View Single Post
08-31-2008, 09:08 AM
#1
Normo is offline Normo
Normo's Avatar
Status: Member
Join date: Aug 2008
Location: Hampshire, UK
Expertise:
Software:
 
Posts: 202
iTrader: 1 / 100%
 

Normo is on a distinguished road

  Old  If...Else If help

Ok so I have an image replacement code I'm working on, but I can't seem to get it working. Can anyone find the problem with this code:

Code:
function ShowImg() {
 if (document.getElementById("1")) {
  document.getElementById("background").src = "images/banner.png";
} else if (document.getElementById("2")) {
  document.getElementById("background").src = "images/text.png";
} else {
  document.getElementById("background").src = "images/bannerthin.png";
}};
Code:
<a href="#" id="1" onmouseover="ShowImg()" onmouseout="Backstep()">1</a>
<a href="#" id="2" onmouseover="ShowImg()" onmouseout="Backstep()">2</a>
What happens is it shows the first image (banner.png) but when you hover over the second link, instead of it showing text.png it shows banner again.
Any help is appreciated.