Posted in jQuery onMay 27, 2020
本文实例为大家分享了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实现鼠标滑动切换图片
- Author -
枫思然声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@