ホームページ  >  記事  >  ウェブフロントエンド  >  Jquery ベースのテキスト スクロール マーキー プラグイン (1 ページ上の複数のスクロール領域)_jquery

Jquery ベースのテキスト スクロール マーキー プラグイン (1 ページ上の複数のスクロール領域)_jquery

WBOY
WBOYオリジナル
2016-05-16 18:22:281274ブラウズ

各ブラウザのテキスト行の高さと互換性があります

コードをコピーします コードは次のとおりです:

(function($ ){
$.fn.extend({
RollTitle: function(opt,callback){
if(!opt) var opt={};
var _this = this ;
_this .timer = null;
_this.lineH = _this.find("li:first").height();
_this.line=opt.line?parseInt(opt.line,15) ):parseInt(_this .height()/_this.lineH,10);
_this.speed=opt.speed?parseInt(opt.speed,10):3000, //スクロール速度、値が大きいほど、速度を遅くします (milli秒
_this.timespan=opt.timespan?parseInt(opt.timespan,13):5000; //スクロール時間間隔 (ミリ秒
if(_this.line==0) this.line= 1;
_this.upHeight=0-_this.line*_this.lineH;
_this.scrollUp=function(){
_this.animate({
marginTop:_this.upHeight
} ,_this.speed, function(){
for(i=1;i_this.find("li:first").appendTo(_this); }
_this .css({marginTop:0});
});
}
_this.hover(function(){
clearInterval(_this.timer);
} ,function(){
_this.timer=setInterval(function(){_this.scrollUp();},_this.timespan)
}).mouseout();
}
})
}) (jQuery);

呼び出しメソッド:
line: 一度にスクロールするテキストの行数
speed: スクロールアニメーション時間
timespan: 間隔時間

コードをコピーします コードは次のとおりです。

;

  • テキスト 2
  • /li>
  • テキスト 5

  • script type="text/javascript ">
    $(document.body).ready(function(){
    $("#RunTopic").RollTitle({line:1,speed:200,timespan: 1500});
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。