Js实现图片轮播,以及鼠标移动选择指定图片
2017-08-17 22:02
861 查看
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> body { text-align: center; } #div1 { width: 800px; height: 300px; background-color: red; margin: 50px auto; position: relative; } #in1 { border: 1px black; position: absolute; right: 50px; bottom: 20px; background-color: pink; width: 30px; height: 30px; line-height: 30px; overflow: hidden; } #in2 { border: 1px black; position: absolute; right: 80px; bottom: 20px; background-color: pink; width: 30px; height: 30px; line-height: 30px; overflow: hidden; } #in3 { border: 1px black; position: absolute; right: 110px; bottom: 20px; background-color: pink; width: 30px; height: 30px; line-height: 30px; overflow: hidden; } #in4 { border: 1px black; position: absolute; right: 140px; bottom: 20px; background-color: pink; width: 30px; height: 30px; line-height: 30px; overflow: hidden; } #img1 { width: 800px; height: 300px; } </style> </head> <body> <div id="div1"> <img src="" id="img1" /> <div id="in1" onmousemove="changeImg4()">4</div> <div id="in2" onmousemove="changeImg3()">3</div> <div id="in3" onmousemove="changeImg2()">2</div> <div id="in4" onmousemove="changeImg1()">1</div> </div> </body> <script> window.onload = imgStart() window.onload = xunhuan() function changeImg4() { setColor(); var img = document.getElementById("img1") img.src = "img/101.jpg"; var div4 = document.getElementById("in1") div4.style.backgroundColor = "red" } function changeImg3() { setColor(); var img = document.getElementById("img1") img.src = "img/102.jpg"; var div3 = document.getElementById("in2") div3.style.backgroundColor = "red" } function changeImg2() { setColor(); var img = document.getElementById("img1") img.src = "img/103.jpg"; var div2 = document.getElementById("in3") div2.style.backgroundColor = "red" } function changeImg1() { setColor(); var img = document.getElementById("img1") img.src = "img/104.jpg"; var div1 = document.getElementById("in4") div1.style.backgroundColor = "red" } function setColor() { var div1 = document.getElementById("in1") var div2 = document.getElementById("in2") var div3 = document.getElementById("in3") var div4 = document.getElementById("in4") div1.style.backgroundColor = "pink" div2.style.backgroundColor = "pink" div3.style.backgroundColor = "pink" div4.style.backgroundColor = "pink" } function imgStart() { setTimeout("changeImg1()", 0) setTimeout("changeImg2()", 2000) setTimeout("changeImg3()", 4000) setTimeout("changeImg4()", 6000) } function xunhuan() { setInterval("imgStart()", 8000) } </script> </html>
相关文章推荐
- JavaScript (实例:实现鼠标移动到图片上后图片放大同时不超出指定范围)
- js实现页面上的图片跟着鼠标箭头移动
- JS实现鼠标移动到缩略图显示大图的图片放大效果
- js实现鼠标移动到图片产生遮罩效果
- js实现图片滚轮放大缩小以及鼠标拖动
- js实现跟随鼠标移动且带关闭功能的图片广告实例
- js实现鼠标左右移动,图片也跟着移动效果
- 新浪微博插入话题后部分文字选中的js实现(控制鼠标指针位置/自动选择指定文本)
- JS 实现banner图片轮播效果(鼠标事件)
- Js中实现图片随鼠标移动——ClientX,ClientY,Position
- JS实现鼠标移动到缩略图显示大图的图片放大效果
- 使用WPF Resource以及Transform等技术实现鼠标控制图片缩放和移动的效果
- 图片使用鼠标移动和滚轮缩放js以及插件
- JS与CSS3实现图片响应鼠标移动放大效果示例
- JS实现图片跟随鼠标移动
- 使用WPF Resource以及Transform等技术实现鼠标控制图片缩放和移动的效果
- js 实现图片间隔循环轮播以及没有间隔的循环轮播
- JS实现图片跟随鼠标移动
- js实现跟随鼠标移动且带关闭功能的图片广告实例
- 利用JS实现基本的图片轮播功能,包括鼠标的经过事件