Basically I transformed a rollover from my css to javascript. I also chose one of the pictures to be selected once the page is loaded. But am having trouble with the onMouseOut event. Everything works perfect except that picture. When I hover over other pictures that picture remains selected. I tried multiple ways but don’t know how to fix it.. any ideas?
<script type="text/javascript">
window.onload=function(){
clicked3();
}
function clicked3(){
document.getElementById("clicked3").style.backgroundPosition = "-198px top";
}
function handleOver3() {
if (document.getElementById("clicked3")) document.style.backgroundPosition="-198px top";
}
function handleOut3() {
if (document.getElementById("clicked3")) document.style.backgroundPosition="0px top";
}
</script>
You don’t showed an registration of handlers for onmouseover and onmouseout events? Next code example may help you.
HTML:
SCRIPT:
http://jsfiddle.net/J2SrF/