1,jquery类级插件开发(用得非常少):

  //1,直接给jquery添加全局函数

  jQuery.myAlert=function(str){
  alert(str);
  }
  jQuery.myAlert2=function(str){
  alert(str);

  //2,用extend()方法
  jQuery.extend({
  myAlert:function(str){
  alert(str);
  },
  myAlert2:function(){
  alert("2222");
  }
  })
  //3,使用命名空间
  jQuery.zxit={
  myAlert:function(str){
  alert(str);
  }
  }

2,jquery对象级插件开发

  ;(function($){

  $.fn.plugin=function(options){
  var defaults={
  //各种参数,各种属性
  }

  var options=$.extend(defaults,options);

  this.each(function(){
  //实现功能的代码
  });
  return this;
  }
  })(jQuery);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-07-01
  • 2021-09-11
  • 2022-12-23
猜你喜欢
  • 2021-05-20
  • 2022-12-23
  • 2022-02-03
  • 2021-11-05
  • 2021-12-05
  • 2021-11-18
相关资源
相似解决方案