效果图:
代码如下:
<!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>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持移动技术网!
如对本文有疑问, 点击进行留言回复!!
【JavaScript笔记(一)】万丈高楼平地起 - 基本概念篇
轻松解决 org.apache.taglibs.standard.tlv.JstlCoreTLV 困惑
vert实践五——Json?Protocol Buffer?FlatBuffers?
[基于tensorflow的人脸检测] 基于神经网络的人脸检测8——验证训练好的神经网络
网友评论