I am trying to use Javascript to change a picture with on-hover. I have a thumbnail image and when the user hovers on top, the big picture will then change, depending on what thumbnail is being hovered over.
This is the HTML I have used.
<img onmouseover="showT(0)" src="pictures/278 Edit 10-8-11 2312.jpg"
height="75" width="75" >
<a href="#" onmouseover="showT(0)">pic 1</a>
<a href="#" onmouseover="showT(1)">pic 2</a>
<a href="#" onmouseover="showT(2)">pic 3</a>
This is the java script placed in header.
<!-- onhover mouse for thumbNail -->
<script language="JavaScript" type="text/JavaScript">
function showT(q){
document.getElementById('ima').setAttribute('src','0'+q+'.jpg')
}
</script>
Here is a way to do it using jQuery:
HTML:
JS (in
<head></head>):You can add jQuery using the repo of Google (in
<head></head>):