先贴代码

(function ( $ ) {
    var id=33;
$.fn.validate=function(options){
    // This is the easiest way to have default options.
    var settings = $.extend({
        // These are the defaults.
        color: "#556b2f",
        backgroundColor: "white"
    }, options );

    // Greenify the collection based on the settings variable.
   alert(settings.color);
    
}
}( jQuery ));

1.jquery插件传递参数通过json

 

2.jquery 函数内默认属性json定义 ,使用$.extend()函数可以在未定义参数时,使用默认参数

var settings = $.extend({
        // 这是默认的参数
        color: "#556b2f",
        backgroundColor: "white"
    }, options );

 

3.定义私有对象

(function ( $ ) {

}( jQuery ));

相关文章:

  • 2022-12-23
  • 2021-05-29
  • 2021-11-25
  • 2021-05-05
  • 2022-12-23
  • 2022-02-11
  • 2022-02-14
  • 2021-06-30
猜你喜欢
  • 2021-10-07
  • 2021-12-11
  • 2021-05-19
  • 2021-10-07
  • 2022-03-02
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案