jQuery实现鼠标滑动切换图片
时间:2020-10-06 21:53:56|栏目:jquery|点击: 次
本文实例为大家分享了jQuery实现鼠标滑动切换图片的具体代码,供大家参考,具体内容如下
<!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>手风琴</title> <script src="./jQuery.js"></script> <style> .bigbox{ width: 610px; height: 270px; border: 1px solid #ccc; margin: 0 auto; } ul{ margin: 0; padding: 0; float: left; height: 270px; } li{ float: left; list-style: none; width: 50px; height: 270px; border: 1px solid #ccc; overflow: hidden; } img{ width: 400px; } .ww{ width: 400px; } </style> </head> <body> <div class="bigbox"> <ul class="q"> <li class="ww"><img src="./image/d1.jpeg" alt=""></li> <li><img src="./image/d2.jpeg" alt=""></li> <li><img src="./image/d3.jpeg" alt=""></li> <li><img src="./image/d4.jpeg" alt=""></li> <li><img src="./image/d5.jpeg" alt=""></li> </ul> </div> <script> $(function(){ $('.q li').mouseover(function(){ $('.q li').removeClass(); $(this).addClass('ww'); }) }) </script> </body> </html>
再补充一段:鼠标移动切换图片操作
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript"> function picture(pic){ //id读取图片及路径 document.getElementById('pic').src='ps/'+pic; } </script> </head> <body> <img id="pic" src="ps/01.jpg" width="400px" //移上去事件 alt="" οnmοuseοver='picture("01.jpg")'οnmοuseοut='picture("02.jpg")' //移出去事件 οnkeydοwn='picture("03.jpg")'> </body> </html>
栏 目:jquery
下一篇:Jquery操作Select 简单方便 一个js插件搞定
本文标题:jQuery实现鼠标滑动切换图片
本文地址:http://www.codeinn.net/misctech/7544.html