I am fairly new to JavaScript and I am trying to make it so that when you mouseover
a link, an image to the right of the page changes, then changes back on mouseout
.
Here is my JavaScript:
function SwapOut(titleid){
if (titleid == video)
document.getElementById("titleimg").src="images/videotitle.png"
else if (titleid == gamedesign)
document.getElementById("titleimg").src="images/gametitle.png"
else if (titleid == webdesign)
document.getElementById("titleimg").src="images/webtitle.png"
return true;
}
function SwapBack('titleid'){
if (titleid == home)
document.getElementById("titleimg").src="images/hometitle.png"
else if (titleid == gamedesign)
document.getElementById("titleimg").src="images/gametitle.png"
else if (titleid == video)
document.getElementById("titleimg").src="images/videotitle.png"
else if (titleid == webdesign)
document.getElementById("titleimg").src="images/webtitle.png"
return true;
}
And my HTML:
<a id="eileenSmall1" href="video.html" onmouseover="SwapOut('video')" onmouseout="SwapBack('home')"></a>
<div id="title">
<img src="images/hometitle.png" name="titleimg"/>
</div>
I would normally approach this with CSS but was having issues getting it to work as I am changing the properties of a different element. Any help would be appreciated!