js實(shí)現(xiàn)產(chǎn)品縮略圖效果
效果圖:
代碼如下:
<!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 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>
以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!
相關(guān)文章
解讀CocosCreator源碼之引擎啟動(dòng)與主循環(huán)
這篇文章主要介紹了CocosCreator源碼解讀之引擎啟動(dòng)與主循環(huán),對(duì)CocosCreator感興趣的同學(xué),可以研究參考一下2021-04-04用于deeplink的js方法(判斷手機(jī)是否安裝app)
這篇文章主要介紹了用于deeplink的js方法(判斷手機(jī)是否安裝app),需要的朋友可以參考下2014-04-04用Node.js通過(guò)sitemap.xml批量抓取美女圖片
這篇文章主要介紹了用Node.js通過(guò)sitemap.xml批量抓取美女圖片的方法和相關(guān)代碼,有需要的小伙伴可以參考下。2015-05-05Mock.js的安裝與使用教程(擺脫后端同學(xué)的束縛)
Mock功能可以根據(jù)接口/數(shù)據(jù)結(jié)構(gòu)定義、Mock規(guī)則配置、Mock?期望配置,自動(dòng)生成模擬數(shù)據(jù),且使用者可以根據(jù)需要靈活構(gòu)造各種結(jié)構(gòu)的接口數(shù)據(jù),下面這篇文章主要給大家介紹了關(guān)于Mock.js的安裝與使用的相關(guān)資料,需要的朋友可以參考下2022-08-08Javascript實(shí)現(xiàn)仿WebQQ界面的“浮云”兼容 IE7以上版本及FF
兼容:IE7以上版本及FF;(騰訊的WebQQ3.0好像也不兼容IE6,其實(shí)這樣挺好的)2011-04-04bootstrap自定義樣式之bootstrap實(shí)現(xiàn)側(cè)邊導(dǎo)航欄功能
bootstrap自帶的響應(yīng)式導(dǎo)航欄是向下滑動(dòng)的,有時(shí)滿足不了個(gè)性化的需求,需要做一個(gè)類似于android drawerLayout 側(cè)滑的菜單,這就是我要實(shí)現(xiàn)的bootstrap自定義側(cè)滑菜單。接下來(lái)通過(guò)本文給大家介紹bootstrap實(shí)現(xiàn)側(cè)邊導(dǎo)航欄功能,感興趣的朋友一起看看吧2018-09-09JS關(guān)于刷新頁(yè)面的相關(guān)總結(jié)
在本篇內(nèi)容中我們給大家整理了關(guān)于JS刷新頁(yè)面的所有相關(guān)知識(shí)點(diǎn)以及整理了相關(guān)的技術(shù)文章,大家可以收藏本頁(yè)面繼續(xù)深入學(xué)習(xí)。2018-05-05