View Full Version : On mouseover image change.
Mario
07-02-2008, 11:57 PM
can someone tell me the code where when you put your mouseover an image it changes into another image? +rep if it works :D
Well im not a genius when it comes to JS but I've tested this and it works I guess..
<script type="text/javascript">
function over(id, up, over)
{
document.getElementById(id).src = over;
}
function out(id, over, up)
{
document.getElementById(id).src = up;
}
</script>
<img src="image_1.png" id="one" onmouseOver="over(this.id, this.src, 'image_1_over.png');" onmouseout="out(this.id, this.src, 'image_1.png)" />
replace the images in the ' ' with the images you want to use
loserWILL
08-02-2008, 01:34 AM
Are you using DIVs styled with CSS?
[Oli]
08-02-2008, 12:53 PM
Yeah, use div's & css, much easyer, cleaner ;) (in my opinion)
basicly you'ld have a css like;
(just change the width & height to whatever size your image is)
#divname{
background-image: url(path/to/image.png);
background-repeat: no-repeat;
width: 100px;
height: 100px;
}
#divname:hover{
background-image: url(path/to/image_hover.png);
background-repeat: no-repeat;
width: 100px;
height: 100px;
}
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.