熟练掌握计算机的操作和管理技能对我们在未来职场的发展是有很大帮助的,下面就让我们一起来欣赏这篇关于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);
}
}
}
}