欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

jquery实现图片翻页效果_jquery

程序员文章站 2022-04-16 19:22:48
...
复制代码 代码如下:

$(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

num = Math.floor(Math.random() * max);

if($.inArray(num, ret) == -1){

ret.push(num);

} else {

i--;

continue;

}

}

return ret;

}

相关标签: 图片翻页