Jquery 學習外掛程式第一天

來源:互聯網
上載者:User

標籤:

<!DOCTYPE html><html> <head>   <meta charset="UTF-8" />   <title>學習外掛程式</title>   <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>   <style>    body{        margin:0;        padding:0;    }    li { list-style:none;width:300px;height:300px;    float:left;}    img{width:100%;height:100%;}    #show ul{        margin:0;        padding:0;        overflow:hidden;    }        img , div{transition:All 0.4s ease-in-out;    -webkit-transition:All 0.4s ease-in-out;    -moz-transition:All 0.4s ease-in-out;    -o-transition:All 0.4s ease-in-out;}        .scale{        transform:scale(1.2);        -webkit-transform:scale(1.2);         -moz-transform:scale(1.2);        -o-transform:scale(1.2);        -ms-transform:scale(1.2);    }</style> </head>   <body> <ul id="show">     <li><img src="1.jpg"/></li>     <li><img src="2.jpg"/></li>     <li><img src="3.jpg"/></li>     <li><img src="4.jpg"/></li>     <li><img src="5.jpg"/></li> </ul> <p style="clear:both;"></p><div style="width:100px;height:100px;background:#ccc;">    </div>      <script type="text/javascript">  (function($) {  $.fn.extend({  "ShowImg": function(options) {      options = $.extend({},{                border: "3px solid red",                height: "100px"            },options);                         //這裡用了$.extend方法,擴充一個對象        /*** return this.hover(function() { //return為了保持jQuery的鏈式操作                  $(this).css({                    "width": options.width,                    "height": options.height                });              },            function() {              $(this).css({                    "width": "100px",                    "height": "100px"                });              });*///            var op = options.border;            return this.click(function(){                var had = $(this).hasClass(‘scale‘);                if(!had){                    $(‘#show‘).find(‘img‘).removeClass(‘scale‘);                    $(‘#show‘).find(‘img‘).css({                        "border": "",                    });                    $(this).addClass(‘scale‘);                    $(this).css({                        "border": "3px solid red",                    })                }else{                    $(this).removeClass(‘scale‘);                    }            })        }    });   })(jQuery);$(function() {  $("img").ShowImg({    });  $("div").ShowImg({    });      // alert($.urlParam());});</script>   </body></html>

 

Jquery 學習外掛程式第一天

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.