私はJavaScriptにかなり慣れていないのでmouseover
、リンクすると、ページの右側の画像が変更され、次に変更されるようにしようとしていますmouseout
.
ここに私の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;
}
そして私の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>
私は通常 CSS でこれにアプローチしますが、別の要素のプロパティを変更しているため、CSS を機能させるのに問題がありました。どんな助けでも大歓迎です!