最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實(shí)現(xiàn)公告文字左右滾動(dòng)的實(shí)例代碼

 更新時(shí)間:2013年10月29日 16:29:28   作者:  
這篇文章介紹了jQuery實(shí)現(xiàn)公告文字左右滾動(dòng)的實(shí)例代碼,有需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jQuery公告文字左右滾動(dòng)效果-m.fzitv.net</title>
<style type="text/css">
#scrollText {
    width: 400px;
    margin-right: auto;
    margin-left: auto;
}
</style>
</head>
<script type="text/javascript" src="/source/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
var ScrollTime;
function ScrollAutoPlay(contID,scrolldir,showwidth,textwidth,steper){
    var PosInit,currPos;
    with($('#'+contID)){
        currPos = parseInt(css('margin-left'));
        if(scrolldir=='left'){
            if(currPos<0 && Math.abs(currPos)>textwidth){
                css('margin-left',showwidth);
            }
            else{
                css('margin-left',currPos-steper);
            }
        }
        else{
            if(currPos>showwidth){
                css('margin-left',(0-textwidth));
            }
            else{
                css('margin-left',currPos-steper);
            }
        }
    }
}

//--------------------------------------------左右滾動(dòng)效果----------------------------------------------
/*
AppendToObj:        顯示位置(目標(biāo)對(duì)象)
ShowHeight:        顯示高度
ShowWidth:        顯示寬度
ShowText:        顯示信息
ScrollDirection:    滾動(dòng)方向(值:left、right)
Steper:        每次移動(dòng)的間距(單位:px;數(shù)值越小,滾動(dòng)越流暢,建議設(shè)置為1px)
Interval:        每次執(zhí)行運(yùn)動(dòng)的時(shí)間間隔(單位:毫秒;數(shù)值越小,運(yùn)動(dòng)越快)
*/
function ScrollText(AppendToObj,ShowHeight,ShowWidth,ShowText,ScrollDirection,Steper,Interval){
    var TextWidth,PosInit,PosSteper;
    with(AppendToObj){
        html('');
        css('overflow','hidden');
        css('height',ShowHeight+'px');
        css('line-height',ShowHeight+'px');
        css('width',ShowWidth);
    }
    if (ScrollDirection=='left'){
        PosInit = ShowWidth;
        PosSteper = Steper;
    }
    else{
        PosSteper = 0 - Steper;
    }
    if(Steper<1 || Steper>ShowWidth){Steper = 1}//每次移動(dòng)間距超出限制(單位:px)
    if(Interval<1){Interval = 10}//每次移動(dòng)的時(shí)間間隔(單位:毫秒)
    var Container = $('<div></div>');
    var ContainerID = 'ContainerTemp';
    var i = 0;
    while($('#'+ContainerID).length>0){
        ContainerID = ContainerID + '_' + i;
        i++;
    }
    with(Container){
      attr('id',ContainerID);
      css('float','left');
      css('cursor','default');
      appendTo(AppendToObj);
      html(ShowText);
      TextWidth = width();
      if(isNaN(PosInit)){PosInit = 0 - TextWidth;}
      css('margin-left',PosInit);
      mouseover(function(){
          clearInterval(ScrollTime);
      });
      mouseout(function(){
          ScrollTime = setInterval("ScrollAutoPlay('"+ContainerID+"','"+ScrollDirection+"',"+ShowWidth+','+TextWidth+","+PosSteper+")",Interval);
      });
    }
    ScrollTime = setInterval("ScrollAutoPlay('"+ContainerID+"','"+ScrollDirection+"',"+ShowWidth+','+TextWidth+","+PosSteper+")",Interval);
}
</script>
<script type="text/javascript">
$(document).ready(function(e) {
    ScrollText($('#scrollText'),23,400,'歡迎光臨腳本之家!','left',1,20);//滾動(dòng)字幕
});
</script>
<body>
<div id="scrollText"></div>
<script type="text/javascript">
if(document.getElementById('GoogleAD')!=null){
    document.getElementById('GoogleAD').innerHTML = '<div class="SearchEngine_AD1">' + document.getElementById('GoogleADCode').innerHTML + '</div>';
}
</script>
</body>
</html>

       

相關(guān)文章

最新評(píng)論

江达县| 宝丰县| 临安市| 余干县| 会昌县| 石屏县| 乾安县| 茂名市| 同心县| 安福县| 涞源县| 廊坊市| 固阳县| 阿尔山市| 拉孜县| 疏勒县| 聂拉木县| 额尔古纳市| 凤阳县| 新民市| 长顺县| 竹山县| 兴业县| 板桥市| 吉木乃县| 吉安市| 呼伦贝尔市| 民和| 岫岩| 上虞市| 乌鲁木齐县| 五常市| 清新县| 鞍山市| 宁德市| 陈巴尔虎旗| 南丹县| 吴川市| 平南县| 孙吴县| 招远市|