仿淘寶首頁(yè)上下滾動(dòng)廣告特效

字號(hào):


    有網(wǎng)友通過(guò)qq群想做一個(gè)淘寶首頁(yè)的上下翻動(dòng)的特效。通過(guò)火狐的firebug查看是通過(guò)層的隱藏和定位來(lái)實(shí)現(xiàn)的。
    我共用了淘寶的內(nèi)容,然后通過(guò)jquery操作對(duì)其進(jìn)行特效實(shí)施。
    查看特效:仿淘寶首頁(yè)上下滾動(dòng)廣告特效
    jquery代碼
    <script language="javascript">
    <!--
    $(function(){
    var $t=Math.floor(Math.random()*3); //隨機(jī)產(chǎn)生一個(gè)1-3數(shù)字 默認(rèn)顯示第幾個(gè)
    $("#upC").click(function(){//向上點(diǎn)擊
    $t++;if($t>=2){$t=2;$(this).addClass("disable");};
    $("#rollContent").animate({"top":-194*$t});
    $("#downC").removeClass("disable");
    $("#numShow > em").text($t*3+"-"+($t+1)*3);
    });
    $("#downC").click(function(){//向下點(diǎn)擊
    $t--;if($t<=0){$t=0;$(this).addClass("disable");}
    $("#rollContent").animate({"top":-194*$t});
    $("#upC").removeClass("disable");
    $("#numShow>em").text($t*3+1+"-"+($t+1)*3);
    });
    $("#numShow>em").text($t*3+1+"-"+($t+1)*3);
    if($t==0)$("#downC").addClass("disable");
    if($t==2)$("#upC").addClass("disable");
    $("#rollContent").animate({"top":-194*$t});
    });
    -->
    </script>
    以上就是代碼嘍!