仿淘寶首頁上下滾動廣告特效

字號:


    有網(wǎng)友通過qq群想做一個淘寶首頁的上下翻動的特效。通過火狐的firebug查看是通過層的隱藏和定位來實現(xiàn)的。
    我共用了淘寶的內(nèi)容,然后通過jquery操作對其進行特效實施。
    查看特效:仿淘寶首頁上下滾動廣告特效
    jquery代碼
    <script language="javascript">
    <!--
    $(function(){
    var $t=Math.floor(Math.random()*3); //隨機產(chǎn)生一個1-3數(shù)字 默認顯示第幾個
    $("#upC").click(function(){//向上點擊
    $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(){//向下點擊
    $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>
    以上就是代碼嘍!