// javascript document (function ($) { $.fn.myscroll = function (options) { //默认配置 var defaults = { speed: 40, //滚动速度,值越大速度越慢 rowheight: 24 //每行的高度 }; var opts = $.extend({}, defaults, options), intid = []; function marquee(obj, step) { obj.find("ul").animate({ margintop: '-=1' }, 0, function () { var s = math.abs(parseint($(this).css("margin-top"))); if (s >= step) { $(this).css("margin-top", 0); marquee(obj, step); } }); } this.each(function (i) { var sh = opts["rowheight"], speed = opts["speed"], _this = $(this); intid[i] = setinterval(function () { if (_this.find("ul").height() <= _this.height()) { clearinterval(intid[i]); } else { marquee(_this, sh); } }, speed); _this.hover(function () { clearinterval(intid[i]); }, function () { intid[i] = setinterval(function () { if (_this.find("ul").height() <= _this.height()) { clearinterval(intid[i]); } else { marquee(_this, sh); } }, speed); }); }); } })(jquery);