jquery实现图片翻页效果
代码如下:
$(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; }
相关推荐
哈嘿Blog 2020-10-26
明月清风精进不止 2020-07-05
PythonMaker 2020-07-05
xirongxudlut 2020-06-28
kkpiece 2020-06-16
qscool 2020-06-12
CloudXli 2020-06-11
vs00ASPNET 2020-06-09
Dimples 2020-06-08
kuoying 2020-06-07
JJandYY 2020-05-31
Wyt00 2020-05-30
liuyh 2020-04-03
CloudXli 2020-05-11
世樹 2020-05-11
bizercsdn 2020-05-10
joyjoy0 2020-05-09