jQuery鼠标滑动切换图片 jQuery实现鼠标滑动切换图片
枫思然 人气:0<!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>
加载全部内容