js滑鼠點擊圖片轉場效果代碼分享_javascript技巧

來源:互聯網
上載者:User

本文執行個體講述了js滑鼠點擊圖片轉場效果。分享給大家供大家參考。具體如下:
實現原理很簡單,其實是多張圖片疊加起來,點擊圖片後依次賦予圖片一個class,使其看起來在表面而已,點擊圖片,可以實現圖片的不斷轉場效果。
運行效果圖:                                      -------------------查看效果-------------------

小提示:瀏覽器中如果不能正常運行,可以嘗試切換瀏覽模式。
為大家分享的js滑鼠點擊圖片轉場效果代碼如下

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>js滑鼠點擊圖片轉場效果</title><style type="text/css">*{margin:0;padding:0;border:none;outline:none;list-style:none;}#wrapper {width:280px;margin:20px auto;}#imageContainer {width:280px;height:280px;position:relative;overflow:hidden;cursor:pointer;}#imageContainer img {position:absolute;top:0;left:0;z-index:1;}#imageContainer img.active {z-index:3;}</style><!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--></head><body><div id="wrapper"> <div id="imageContainer"> <img src="images/01.jpg" class="active" width="280" height="280" /> <img src="images/02.jpg" width="280" height="280" /> <img src="images/03.jpg" width="280" height="280" /> </div></div><script src="js/jquery.min.js"></script><script>var imageObject = { clickSwap : function(obj) { obj.click(function() { var activeImage = $(this).children('img.active'); activeImage.removeClass('active'); if (activeImage.next().length > 0) { activeImage.next().addClass('active'); } else { $(this).children('img:first-child').addClass('active'); } return false; }); }};$(function() { imageObject.clickSwap($('#imageContainer'));});</script></body></html>

以上就是為大家分享的js滑鼠點擊圖片轉場效果代碼,希望大家可以喜歡。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.