简单的图片切换

Original 2019-03-18 19:13:24 259
abstract:实现一个简单的图片切换 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=
实现一个简单的图片切换
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>js</title>
<style>

</style>
</head>

<body>

<img class="img1" src="http://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg" alt="">
<script>
window.onload = function () {
// var div = document.getElementsByTagName('div')[0];
var img1 = document.getElementsByClassName('img1')[0];
// var img2 = document.getElementsByClassName('img2')[0];
img1.onmouseover = function () {
img1.src = 'http://img.php.cn/upload/article/000/000/003/5b49b0e610f26951.jpg';
}
img1.onmouseout = function () {
img1.src = 'http://img.php.cn/upload/article/000/000/003/5a9675a3b2106284.jpg';
}
}
</script>
</body>

</html>


Correcting teacher:灭绝师太Correction time:2019-03-19 09:23:23
Teacher's summary:完成的不错哦 , 知道学以致用 ,继续加油!

Release Notes

Popular Entries