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

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

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

    jQuery定義背景動態(tài)切換效果的方法
    來源:易賢網(wǎng) 閱讀:1682 次 日期:2015-03-25 11:12:35
    溫馨提示:易賢網(wǎng)小編為您整理了“jQuery定義背景動態(tài)切換效果的方法”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了jQuery定義背景動態(tài)切換效果的方法,實例分析了jQuery操作圖片的技巧,具有一定參考借鑒價值,需要的朋友可以參考下

    本文實例講述了jQuery定義背景動態(tài)切換效果的方法。分享給大家供大家參考。具體如下:

    通過下面的jQuery插件,你可以將圖片放在一個數(shù)組里,然后告訴jQuery圖片需要在什么地方背景輪換

    (function($){

    var defaultSettings;

    var divfg, divbg;

    var fadeInterval;

    var fqTimer;

    var currImg = 0;

    var displImg = 0;

    var running = false;

    // Setup settings and initialize the plugin

    $.fn.bgFade = function(settings, callback){

    defaultSettings = $.extend({

    frequency: 5000,

    speed: 10,

    images: [],

    position: "center center",

    fgz: 1,

    bgz: 0

    }, settings);

    var c = 0;

    $(this).each(function(){

    if(c == 0) divfg = $(this);

    if(c == 1) divbg = $(this);

    c++;

    });

    setBackgrounds();

    if(typeof callback == "function"){

    callback();

    }

    return this;

    };

    // Start the fadder

    $.fn.start = function(){

    fqTimer = setTimeout(function(){

    nextFade()},defaultSettings.frequency

    );

    running = true;

    return this;

    };

    // Stop the fadder

    $.fn.stop = function(){

    clearInterval(fadeInterval);

    clearTimeout(fqTimer);

    running = false;

    return this;

    }

    // Get the current image info {array id, image url}

    $.current = function(){

    return {pos: displImg, url: defaultSettings.images[displImg]}

    }

    // Set the first two backgrounds

    function setBackgrounds(){

    image1 = defaultSettings.images[0];

    image2 = defaultSettings.images[1];

    divfg.css({

    backgroundImage: "url('"+image1+"')",

    zIndex: defaultSettings.fgz,

    backgroundPosition: defaultSettings.postion

    });

    divbg.css({

    backgroundImage: "url('"+image2+"')",

    zIndex: defaultSettings.bgz,

    backgroundPosition: defaultSettings.postion

    });

    currImg = 1;

    displImg = 0;

    }

    // Set the next background after a fade completes

    function setNextBackground(){

    next = arrayNext();

    image = defaultSettings.images[next];

    divbg.css({

    backgroundImage: "url('"+image+"')"

    });

    setTimeout(function(){nextFade()}, defaultSettings.frequency);

    }

    // Run a fade

    function nextFade(){

    fadeInterval = setInterval(function(){fadeIt()}, 30);

    }

    // Decrement the opacity of the div

    function fadeIt(){

    if(divfg.css("opacity") == ''){

    op = 1;

    }else{

    op = divfg.css("opacity");

    }

    op -= ((1000 * defaultSettings.speed) / 30) * 0.0001;

    divfg.css("opacity", op);

    if(op <= 0){

    bg = divbg;

    bgimg = divbg.css("background-image");

    divfg.css("opacity", "1");

    divfg.css("background-image", bgimg);

    clearInterval(fadeInterval);

    setNextBackground();

    displImg = arrayCurrent();

    }

    }

    // Get the next item in the array

    function arrayNext(){

    var next = currImg + 1;

    if(next >= defaultSettings.images.length){

    next = 0;

    }

    currImg = next;

    return next;

    }

    // Get the current item in the array

    function arrayCurrent(){

    var cur = currImg - 1;

    if(cur < 0)

    cur = defaultSettings.images.length - 1;

    return cur;

    }

    })(jQuery);

    希望本文所述對大家的jQuery程序設(shè)計有所幫助。

    更多信息請查看IT技術(shù)專欄

    更多信息請查看腳本欄目
    易賢網(wǎng)手機(jī)網(wǎng)站地址:jQuery定義背景動態(tài)切換效果的方法
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

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

    • 報班類型
    • 姓名
    • 手機(jī)號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點 | 投訴建議
    工業(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)警報警專用圖標(biāo)