zoukankan      html  css  js  c++  java
  • 一个简单的jQuery插件的写法 tableUI

     一直搞PHP,看来以后还要搞jQuery或者js了,来一段代码,找找写插件的思路

    /*
     * tableUI 1.0
     * Copyright (c) 2009 sunscheung  http://www.cnblogs.com/sunscheung/
     * Date: 2015-08-07
     * 使用方法:假设table的class为table_solid  
     * 接口:<script type="text/javascript">
                 $(function(){
                    $(".table_solid").tableUI();
                 });
             </script>
     */
    (function($){
        $.fn.tableUI = function(options){
            //属性
            var defaults = {
                evenRowClass:"evenRow",
                oddRowClass:"oddRow",
                activeRowClass:"activeRow",
                clickRowClass:"clickRow"
            };
            var options = $.extend(defaults, options);
            this.each(function(){
                var thisTables = $(this);
                $(thisTables).find("tr:even").addClass(options.evenRowClass);
                $(thisTables).find("tr:odd").addClass(options.oddRowClass);
                $(thisTables).find("tr").bind("mouseover",function(){
                    $(this).removeClass(options.clickRowClass).addClass(options.activeRowClass);
                });
                $(thisTables).find("tr").bind("mouseout",function(){
                    $(this).removeClass(options.clickRowClass).removeClass(options.activeRowClass);
                });
                 $(thisTables).find("tr").bind("click",function(){
                    $(this).addClass(options.clickRowClass);
                });
            });
        };
    })(jQuery);
  • 相关阅读:
    SHELL
    终端如何输出彩色字体
    BTree和B+Tree详解
    博客项目----小功能模块
    python的学习之旅---Mysql数据库
    Python的学习之旅———协程
    python的学习之旅---信号量 定时器
    python的学习之旅---回调机制
    Python的学习之旅———线程 事件
    centos安装redis
  • 原文地址:https://www.cnblogs.com/sunscheung/p/4710933.html
Copyright © 2011-2022 走看看