上下滾動的例項
html:
<div class="rightbtm box">
<div class="uls">
<p><a href="#"><span class="span1s">[出售資訊]</span>樣品中心報名流程與操作指南</a></p>
<p><a href="#"><span class="span2s">[求購資訊]</span>杭州農業有限公司求購牛奶300箱..</a></p>
<p><a href="#"><span class="span2s">[求購資訊]</span>襄陽傲農現代常年求購車釐子..</a></p>
<p><a href="#"><span class="span3s">[轉讓資訊]</span>餘杭良渚街道一塊農林用地轉讓。</a></p>
<p><a href="#"><span class="span1s">[轉讓資訊]</span>千島湖農家樂一處轉讓</a></p>
<p><a href="#"><span class="span2s">[出售資訊]</span>10只大閘蟹 求買主</a></p>
</div>
</div>
js:
(function($){
$.fn.scrollTop = function(options){
var defaults = {
speed:30
}
var opts = $.extend(defaults,options);
this.each(function(){
var $timer;
var scroll_top=0;
var obj = $(this);
var $height = obj.find(".uls").height();
obj.find(".uls").clone().appendTo(obj);
obj.hover(function(){
clearInterval($timer);
},function(){
$timer = setInterval(function(){
scroll_top++;
if(scroll_top > $height){
scroll_top = 0;
}
obj.find(".uls").first().css("margin-top",-scroll_top);
},opts.speed);
}).trigger("mouseleave");
})
}
})(jQuery);$(function(){
$(".box").scrollTop({
speed:60 //數值越大 速度越慢
});
})