醉梦半醒的博客

javascript实现图片变换

字数统计: 74阅读时长: 1 min
2018/06/27 Share

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>

<img src="hack.jpg" id="image">
<script>
var test=document.getElementById("image");
function change1(){
test.src="1.jpg";
}
function change2(){
test.src="2.jpg";
}
test.onmouseover=change1;
test.onmouseout=change2;

</script>

</body>
</html>
CATALOG