你的位置:首页 > 软件开发 > Java > jquery插件方式实现table查询功能

jquery插件方式实现table查询功能

发布时间:2016-06-05 23:01:06
1.写插件部分,如下:;(function($){  $.fn.plugin = function(options){    var defaults = {      //各种属性,各种参数    }    var options = $.extend(defaults, ...

1.写插件部分,如下:

;(function($){

  $.fn.plugin = function(options){

    var defaults = {

      //各种属性,各种参数

    }

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

     this.each(function(){

      //功能代码

      var _this = this;

    });

  }

})(jQuery);

附上一个例子:

 1 ;(function($){ 2   $.fn.table = function(options){ 3   var defaults = { 4       //arguments , properties 5       evenRowClass : 'evenRow', 6       oddRowClass : 'oddRow', 7       currentRowClass : 'currentRow', 8       eventType : 'mouseover', 9       eventType2 : 'mouseout',10     }  11     var options = $.extend(defaults, options);12 13     this.each(function(){14 15       //function code16       var _this = $(this);17       //even row18       _this.find('tr:even:not("#thead")').addClass(options.evenRowClass);19       //_this.find('#thead').removeClass(options.evenRowClass);20       // odd row 21       _this.find('tr:odd').addClass(options.oddRowClass);22 23       /*_this.find('tr').mouseover(function(){24         $(this).addClass(options.currentRowClass);25       }).mouseout(function(){26         $(this).removeClass(options.currentRowClass);27       });*/28 29       _this.find('tr').bind(options.eventType, function(){30         $(this).addClass(options.currentRowClass);31       });32 33       _this.find('tr').bind(options.eventType2, function(){34         $(this).removeClass(options.currentRowClass);35       });36 37     });38     return this;39   }40 })(jQuery);

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:jquery插件方式实现table查询功能

关键词:jquery

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录