jQuery插件

常用插件:

Validation:

  表单验证插件。

Form:

  表单提交插件。

SimpleModal:

  模态窗口插件。

Cookie:

  Cookie管理插件。

编写插件:

  插件类型:

  • 封装对象方法的插件。
1 ;(function($){
2     $.fn.extend({
3         "color":function(value){
4             return this.css("color",value);
5         }
6     });
7 })(jQuery);
  • 封装全局函数的插件。
 1 ;(function($){
 2     $.extend({
 3         ltrim:function(text){
 4             return (text || "").replace(/^\s+/g,"");
 5         },
 6         rtrim:function(text){
 7             return (text || "").replace(/\s+$/g,"");
 8         }
 9     });
10 })(jQuery);
  • 选择器插件。
1 ;(function($){
2     $.extend($.expr[":"],{
3         between : function(a,i,m){
4             var tmp = m[3].split(",");
5             return tmp[0]-0 < i && i < tmp[1] - 0;
6         }
7     });
8 })(jQuery);

 

你可能感兴趣的:(jQuery插件)