您现在的位置: 万盛学电脑网 >> 程序编程 >> 数据库 >> 数据库综合 >> 正文

jQuery实现公告文字左右滚动的实例教程

作者:佚名    责任编辑:admin    更新时间:2022-06-22

本文导航

1、首页2、左右滚动效果-2

熟练掌握计算机的操作和管理技能对我们在未来职场的发展是有很大帮助的,下面就让我们一起来欣赏这篇关于jQuery实现公告文字左右滚动的实例的文章吧!

#scrollText {

width: 400px;

margin-right: auto;

margin-left: auto;

}

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);

}

}

}

}