zoukankan      html  css  js  c++  java
  • Jquery 学习插件第一天

    <!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;300px;height:300px;
        float:left;}
        img{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="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>
    人如代码,规矩灵活;代码如诗,字句精伦。
  • 相关阅读:
    数据库索引学习
    JavaScript提高:002:ASP.NET使用easy UI实现tab效果
    jQuery效果之显示与隐藏
    leetcode
    走进Struts2(五)— 值栈和OGNL
    Html中的超链接
    再理解 as3.0接口
    easyui combobox 三级级联 input 两种实现
    三层登录实例VB.NET版具体解释---理论加实战篇
    如何用Delphi开发网游外挂
  • 原文地址:https://www.cnblogs.com/xinlinux/p/4193209.html
Copyright © 2011-2022 走看看