• JQ效果:随便看看


    $(function($){
        $.fn.changeList = function(options){
            var defaults = {
                        tag : 'li', // tab name
                        subName : '.utilTabSub', // sub class name
                        eventType : 'click', // event type
                        num : 4,
                        showType : 'show' // show effect type
                    },
                    opts = $.extend({}, defaults, options),
                    that = $(this),
                    subUl = that.find(opts.subName),
                    subItems = subUl.find('li'),
                    size = subItems.length,
                    liW = subItems.outerWidth(true),
                    ulW = liW * size,
                    page = size + 1,
                    n = opts.num,
                    randNum = 0,
                    m = 0;

            if(size > n){
                that.find(opts.tag)[opts.eventType](function() {
                    randNum = mathRand(n, size);
                    subItems.hide();
                    $.each(randNum, function (i, el) {
                        subItems.eq(el).fadeIn(800);
                    });
                });
            }
        };
    }(jQuery));

    /**
     * create Random number
     * @param bit: number
     * @param max: max number
     * @return {Array}
     
    */
    function mathRand(bit, max){
        var num = 0,
                arr = [],
                ret = [];
        for(var i=0; i<bit; i++){
            num = Math.floor(Math.random() * max);
            if($.inArray(num, ret) == -1){
                ret.push(num);
            } else {
                i--;
                continue;
            }
        }
        return ret;
    }

  • 相关阅读:
    结对项目进度1
    学期总结之数学建模软件——LINGO和R
    四则运算计算程序(完成)
    学期总结之数学建模软件——编译原理
    图形学算法之NichollLeeNicholl算法
    学期总结之3D游戏开发
    《构建之法》读后感
    四则运算计算程序(初步)
    结对项目进度2
    Spring IOC原理解析
  • 原文地址:https://www.cnblogs.com/jikey/p/2831691.html
Copyright © 2020-2023  润新知