I'm new to Javascript trying to make a image gallery. But my code only show first pic in right div. and it won't change though I used onmouseover. When I try to switch picture, it doesn't has any reaction. Could anyone help me with it? Thank you!!
<html>
<head>
<meta charset="UTF-8">
<title>Image Gallery</title>
<style>
body{
margin:0;
padding:0;
}
#menu li{
list-style-type:none;
}
#menu li img{
height:80px;
width:100px;
}
#left {
float:left;
margin:30px;
}
#right{
height:400px;
widows:600px;
float:left;
margin:30px;
}
</style>
<script>
window.onload = test;
function test (){
var right = document.getElementById("right");
var list = document.getElementsByTagName("img");
for(var i= 0;i<list.length;i++){
var img = list[i];
list[i].onmouseover = showPic(list[i]);
list[i].onmouseout = hidPic(list[i]);
}
}
function showPic(obj){
var right = document.getElementById("right");
right.appendChild(obj);
}
function hidPic(obj){
var right = document.getElementById("right");
right.removeChild(obj);
}
</script>
</head>
<body>
<div id="left">
<ul id="menu">
<li><img src="1.jpg"/></li>
<li><img src="2.jpg"/></li>
<li><img src="3.jpg"/></li>
<li><img src="4.jpg"/></li>
<li><img src="5.jpg"/></li>
</ul>
</div>
<div id="right">
</div>
</body>
</html>