jQuery实现鼠标滑过商品小图片上显示对应大图片

本文实例讲述了jQuery实现鼠标滑过商品小图片上显示对应大图片功能。分享给大家供大家参考,具体如下:

1 . 效果截图

jQuery实现鼠标滑过商品小图片上显示对应大图片

2 . 代码

<!doctype html> <html> <head> <meta charset="utf-8"> <title> jQuery图片变换</title> </head> <style type="text/css"> .show{width:330px; height:auto; margin:50px auto; background:#eee} .item{background:#fff; width:300px; height:auto; float:left; margin:15px;} p{ padding:15px; color:#ff6600} .big-photo img{ width:300px; height:300px; border:1px solid #e0e0e0} .des-small img{ width:30px; height:30px;border:1px solid #e0e0e0; } .des-small img:hover{ border:1px solid #ff6600} .clear{clear:both} </style> <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript"> $(function() { /** 更换小图片 */ $(".item a").hover(function(){ changeImg($(this)) }); }); function changeImg(obj){ if(obj.find("img").attr("alt")=="small"){ var temp_big_src = obj.siblings('a').find('img[alt=big]').attr('src'); var temp_big_url = obj.siblings('a[class=big-photo]').attr('href'); var temp_small_src = obj.find('img').attr('src'); var temp_small_url = obj.attr('href'); obj.siblings('a').find('img[alt=big]').attr('src',temp_small_src); } } </script> <body> <div> <p>Jquery实现鼠标移动/移过到商品小图片上时替换掉大图片上的图片</p> <div> <a> <img src="https://www.jb51.net/WR_00001.jpg" alt="big"/> </a> <a> <img src="https://www.jb51.net/WR_00002.jpg" alt="small"/> </a> <a> <img src="https://www.jb51.net/WR_00003.jpg" alt="small"/> </a> <a> <img src="https://www.jb51.net/WR_00004.jpg" alt="small"/> </a> </div> <div></div> </div> </body> </html>

附:完整实例代码点击此处本站下载

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery切换特效与技巧总结》、《jQuery动画与特效用法总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结

希望本文所述对大家jQuery程序设计有所帮助。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/e7e58fc4bedb8b617685f83c29d14960.html