HTML
<div class="other"> <ul id="other"> <li><span></span><span>192.168.0.1</span><span>SQL注入</span><span>02-24 13:01:45</span></li> <li><span></span><span>192.168.0.1</span><span>SQL注入</span><span>02-24 13:02:45</span></li> <li><span></span><span>192.168.0.1</span><span>SQL注入</span><span>02-24 13:03:45</span></li> <li><span></span><span>192.168.0.1</span><span>SQL注入</span><span>02-24 13:04:45</span></li> <li><span></span><span>192.168.0.1</span><span>SQL注入</span><span>02-24 13:05:45</span></li> <li><span></span><span>192.168.0.1</span><span>SQL注入</span><span>02-24 13:06:45</span></li> </ul> </div>
调用函数
getScroll(".basics", 10000);
封装函数
//文本间隔滚动效果; function getScroll(className, timer) { var $this = $(className); var scrollTimer; $this.hover(function () { clearInterval(scrollTimer); }, function () { scrollTimer = setInterval(function () { scrollContent($this); }, timer); }).trigger("mouseout"); } function scrollContent(obj) { var $self = obj.find("ul:first"); var lineHeight = $self.find("li:first").height(); $self.animate({ "margin-top": -lineHeight + "px" }, 1000, function () { $self.css({ "margin-top": "0px" }).find("li:first").appendTo($self); }) }
lockdatav Done!