首页 / JAVASCRIPT / js实现产品缩略图效果
js实现产品缩略图效果
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了js实现产品缩略图效果,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2451字,纯文字阅读大概需要4分钟。
内容图文
![js实现产品缩略图效果](/upload/InfoBanner/zyjiaocheng/346/36b0b92756e9427699cff6ad2e4123fc.jpg)
效果图:
代码如下:
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script> <link href="http://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="external nofollow" rel="stylesheet"> <script src="http://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script> </head> <script> $(function(){ $("img.smallImage").mouseenter(function(){ var bigImageURL = $(this).attr("bigImageURL"); $("img.bigImg").attr("src",bigImageURL); }); $("img.bigImg").load( function(){ $("img.smallImage").each(function(){ var bigImageURL = $(this).attr("bigImageURL"); img = new Image(); img.src = bigImageURL; img.onload = function(){ console.log(bigImageURL); $("div.img4load").append($(img)); }; }); } ); }); </script> <style> div.imgAndInfo{ margin: 40px 20px; } div.imgInimgAndInfo{ width: 400px; float: left; } div.imgAndInfo img.bigImg{ width: 400px; height: 400px; padding: 20px; border: 1px solid #F2F2F2; } div.imgAndInfo div.smallImageDiv{ width: 80%; margin: 20px auto; } div.imgAndInfo img.smallImage{ width: 60px; height: 60px; border: 2px solid white; } div.imgAndInfo img.smallImage:hover{ border: 2px solid black; } </style> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <div class="imgAndInfo"> <div class="imgInimgAndInfo"> <img width="100px" class="bigImg" src="http://how2j.cn/tmall/img/productSingle/8619.jpg"> <div class="smallImageDiv"> <img width="100px" class="smallImage" src="http://how2j.cn/tmall/img/productSingle_small/8620.jpg" bigImageURL="http://how2j.cn/tmall/img/productSingle/8620.jpg"> <img width="100px" class="smallImage" src="http://how2j.cn/tmall/img/productSingle_small/8619.jpg" bigImageURL="http://how2j.cn/tmall/img/productSingle/8619.jpg"> <img width="100px" class="smallImage" src="http://how2j.cn/tmall/img/productSingle_small/8618.jpg" bigImageURL="http://how2j.cn/tmall/img/productSingle/8618.jpg"> <img width="100px" class="smallImage" src="http://how2j.cn/tmall/img/productSingle_small/8617.jpg" bigImageURL="http://how2j.cn/tmall/img/productSingle/8617.jpg"> <img width="100px" class="smallImage" src="http://how2j.cn/tmall/img/productSingle_small/8616.jpg" bigImageURL="http://how2j.cn/tmall/img/productSingle/8616.jpg"> </div> <div class="img4load hidden" ></div> </div> <div style="clear:both"></div> </div>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持脚本之家!
内容总结
以上是互联网集市为您收集整理的js实现产品缩略图效果全部内容,希望文章能够帮你解决js实现产品缩略图效果所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。