当前位置: 代码迷 >> Web前端 >> 扩张Jquery
  详细解决方案

扩张Jquery

热度:105   发布时间:2012-11-18 10:51:22.0
扩展Jquery
1. 为jQuery添加全局函数
       jQuery.foo=function(){
          alert('ddd');
       }
      
       jQuery.foo() or $.foo()
      
2. 定义插件

    jQuery.myPlugin={
       foo:function(){
         alert("foo");
       },
       bar:function(){
         alert("bar");
       }
    }
   
3. 为JQuery对象添加方法

     jQuery.fn.test=function(){
        alert("Test");
     }
    
     $('div').test();
    
4. 用jQuery.extend 扩展原有对象
     var obj={height:'20'};
     jQuery.extend(obj, {
    project: 'athena',
    engine: 'flash',
    flash:'/util/jStore.Flash.html'
     });
    
     为obj 添加三个新属性
  相关解决方案