zoukankan      html  css  js  c++  java
  • JS 框架

    <html xmlns=”http://www.w3.org/1999/xhtml”> 
    <head> 
    <title>Untitled Page</title> 
    </head> 
    <body> 
    <div id="d">divvv</div> 
    <div id="fsd">fdsf</div> 
    </body> 
    </html> 
    <script type="text/javascript">
    
    
    var myok = function(selector){ 
    debugger;
    alert(typeof(this));
    } 
    var c = new myok('d');
    alert(c.constructor);
    //实现自己的MyQuery框架 
    var MyQuery = function(selector){ 
    debugger;
    if ( window == this ) return new MyQuery(selector); 
    //这里只实现dom类型的简单查找,嘿嘿 
    var doms = document.getElementsByTagName(selector); 
    var arr = []; 
    for(var i=0; i<doms .length; i++){ 
    arr.push(doms.item(i)); 
    } 
    return this.setArray(arr); 
    } 
    MyQuery.prototype.setArray = function( arr ) { 
    debugger;
    this.length = 0; 
    [].push.apply( this, arr ); 
    return this; 
    } 
    MyQuery.fn = MyQuery.prototype; 
    var $ = MyQuery;
    
    //插件扩展1)each 
    MyQuery.fn.each = function(method){ 
    debugger;
    for(var i=0,l=this.length; i<l; i++){ 
    method.call(this[i],i); 
    } 
    }
    
    //插件扩展2)show 
    MyQuery.fn.show = function(){ 
    debugger;
    this.each(function(i){ 
    alert(i+":"+this.id+":"+this.innerHTML); 
    }); 
    } 
    //debugger 
    $("div").show(); 
    </script>
  • 相关阅读:
    PHP(运算符,语句,函数)
    数据库高级查询
    MySQL数据库常用函数
    mySQL数据库数据查询操作详解
    mySQL数据库设计范式及增删改查操作
    mySQL-创建表
    JavaScript-选项卡
    JavaScript做DIV下拉列表
    JavaScript-事件
    JavaScript函数-递归
  • 原文地址:https://www.cnblogs.com/msdn1433/p/3534276.html
Copyright © 2011-2022 走看看