jquery enables multi-line text picture scrolling effect

Source: Internet
Author: User
Tags extend time interval

Today share a jquery implementation for multiple-line scrolling effects.

I look at some forum websites, the bulletin is used more.

The code is as follows Copy Code

Multi-line scrolling
(function ($) {
$.fn.extend ({
Scroll:function (Opt,callback) {
if (!opt) var opt={};
var _this=this.eq (0). Find ("Ul:first");
var lineh=_this.find ("Li:first"). Height (),
Line=opt.line?parseint (opt.line,10):p Arseint (This.height ()/lineh,10),
Speed=opt.speed?parseint (opt.speed,10): 1000,//scrolling speed, the larger the number, the slower the speed (milliseconds)
Timer=opt.timer?parseint (opt.timer,10): 5000; Time interval for scrolling (milliseconds)
if (line==0) line=1;
var Upheight=0-line*lineh;
Scrollup=function () {
_this.animate ({
Margintop:upheight
},speed,function () {
for (i=1;i


Example Demo

The code is as follows Copy Code

<div id= "Scrolldiv" >
<ul>
<li> I am jquery multi-line scroll bar one </li>
<li> I am jquery multi-line scroll bar two </li>
<li> I am jquery multi-line scroll bar three </li>
<li> I am jquery multi-line scroll bar four </li>
<li> I am jquery multi-line scroll bar five </li>
<li> I am jquery multi-line scroll bar six </li>
<li> I am jquery multi-line scroll bar seven </li>
<li> I am jquery multi-line scroll bar eight </li>
</ul>
</div>.


<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" ></ Script>
<script type= "Text/javascript" >
Multi-line scrolling
(function ($) {
$.fn.extend ({
Scroll:function (Opt,callback) {
if (!opt) var opt={};
var _this=this.eq (0). Find ("Ul:first");
var lineh=_this.find ("Li:first"). Height (),
Line=opt.line?parseint (opt.line,10):p Arseint (This.height ()/lineh,10),
Speed=opt.speed?parseint (opt.speed,10): 1000,//scrolling speed, the larger the number, the slower the speed (milliseconds)
Timer=opt.timer?parseint (opt.timer,10): 5000; Time interval for scrolling (milliseconds)
if (line==0) line=1;
var Upheight=0-line*lineh;
Scrollup=function () {
_this.animate ({
Margintop:upheight
},speed,function () {
for (i=1;i<=line;i++) {
_this.find ("Li:first"). Appendto (_this);
}
_this.css ({margintop:0});
});
}
_this.hover (function () {
Clearinterval (Timerid);
},function () {
Timerid=setinterval ("Scrollup ()", timer);
}). Mouseout ();
}
})
}) (JQuery);
$ (document). Ready (function () {
$ ("#scrollDiv"). Scroll ({line:4,speed:1000,timer:2000});
});
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.