富贵资源网 Design By www.hznty.com

复制代码 代码如下:
$(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;

}

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com