第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關(guān)于文字滾動的問題

關(guān)于文字滾動的問題

下面是文字向上滚动的代码,这里面为什么要设置controls={}, 而且后面的元素选择也用到了。还有里面的this.init=function(){}为什么要赋值给this.init。下面的new scrollTxt().init();是什么意思呢?初学者多多指教 function  scrollTxt(){     var controls={},         values={},         t1=200, /*播放动画的时间*/         t2=2000, /*播放时间间隔*/         si;     controls.rollWrap=$("#roll-wrap");     controls.rollWrapUl=controls.rollWrap.children();     controls.rollWrapLIs=controls.rollWrapUl.children();     values.liNums=controls.rollWrapLIs.length;     values.liHeight=controls.rollWrapLIs.eq(0).height();     values.ulHeight=controls.rollWrap.height();     this.init=function(){         autoPlay();         pausePlay();     }     /*滚动*/     function play(){         controls.rollWrapUl.animate({"margin-top" : "-"+values.liHeight}, t1, function(){             $(this).css("margin-top" , "0").children().eq(0).appendTo($(this));         });     }     /*自动滚动*/     function autoPlay(){         /*如果所有li标签的高度和大于.roll-wrap的高度则滚动*/         if(values.liHeight*values.liNums > values.ulHeight){             si=setInterval(function(){                 play();             },t2);         }     }     /*鼠标经过ul时暂停滚动*/     function pausePlay(){         controls.rollWrapUl.on({             "mouseenter":function(){                 clearInterval(si);             },             "mouseleave":function(){                 autoPlay();             }         });     } } new scrollTxt().init();
查看完整描述

1 回答

已采納
?
林逸舟丶

TA貢獻124條經(jīng)驗 獲得超28個贊

1.為什么var controls={}:

????因為通過定義controls為一個對象,才能在后面對其屬性進行賦值:

??controls.rollWrap=$("#roll-wrap");
??controls.rollWrapUl=controls.rollWrap.children();
??controls.rollWrapLIs=controls.rollWrapUl.children();

????后面values={}同理。

2.賦值給this.init:

????this指向scrollTxt(),通過this.init賦值一個方法(function),才能有最后的new?scrollTxt().init()執(zhí)行方法。

3.new scrollTxt().init()即執(zhí)行init這個方法

function(){
????autoPlay();
????pausePlay();
}


查看完整回答
反對 回復(fù) 2018-01-04
  • 1 回答
  • 0 關(guān)注
  • 1202 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號