茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    jQuery文字橫向滾動效果的實(shí)現(xiàn)代碼
    來源:易賢網(wǎng) 閱讀:4255 次 日期:2016-06-17 15:51:24
    溫馨提示:易賢網(wǎng)小編為您整理了“jQuery文字橫向滾動效果的實(shí)現(xiàn)代碼”,方便廣大網(wǎng)友查閱!

    很多網(wǎng)站都有公告,并且都喜歡用橫向滾動的方式來展現(xiàn)。最近自己用jQuery也寫了文字橫向滾動,實(shí)現(xiàn)了自定義滾動速度,鼠標(biāo)經(jīng)過時(shí)暫停的功能。

    HTML代碼如下:

    代碼如下:

    <div id="s" style="width:100px; position:relative; white-space:nowrap; overflow:hidden; height:20px;">

    <div id="noticeList" style="position:absolute; top:0; height:20px;"><span>jQuery文字橫向滾動</span><span>jQuery制作文字橫向滾動</span><span>www.jb51.net</span></div>

    </div>

    JS代碼:

    方法一:

    $.fn.textScroll=function(){

    var speed=60,flag=null,tt,that=$(this),child=that.children();

    var p_w=that.width(), w=child.width();

    child.css({left:p_w});

    var t=(w+p_w)/speed * 1000;

    function play(m){

    var tm= m==undefined ? t : m;

    child.animate({left:-w},tm,"linear",function(){

    $(this).css("left",p_w);

    play();

    });

    }

    child.on({

    mouseenter:function(){

    var l=$(this).position().left;

    $(this).stop();

    tt=(-(-w-l)/speed)*1000;

    },

    mouseleave:function(){

    play(tt);

    tt=undefined;

    }

    });

    play();

    }

    方法二:

    $.fn.textScroll=functioon(){

    var p = $(this),

    c = p.children(),

    speed=3000;// 值越大,速度越小

    var cw = c.width(),pw=p.width();

    var t = (cw / 100) * speed;

    var f = null, t1 = 0;

    function ani(tm) {

    counttime();

    c.animate({ left: -cw }, tm, "linear", function () {

    c.css({ left: pw });

    clearInterval(f);

    t1 = 0;

    t=((cw+pw)/100)*speed;

    ani(t);

    });

    }

    function counttime() {

    f = setInterval(function () {

    t1 += 10;

    }, 10);

    }

    p.on({

    mouseenter: function () {

    c.stop(false, false);

    clearInterval(f);

    console.log(t1);

    },

    mouseleave: function () {

    ani(t - t1);

    console.log(t1);

    }

    });

    ani(t);

    }

    最后調(diào)用$("#s").textScroll();

    以上這篇jQuery文字橫向滾動效果的實(shí)現(xiàn)代碼就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:jQuery文字橫向滾動效果的實(shí)現(xiàn)代碼
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報(bào)班

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)