console
$(document).ready(function(){
setInterval(function(){
$("p").animate({
marginLeft:"-=1"
},15,function(){
var s = Math.abs(parseInt($(this).css("margin-left")));
if(s>=200){
$(this).css("margin-left","0px");
console.log(s)
}
});
});
});
<div >
<p >请勿使用电脑 请勿使用电脑</p>
<button>替换文字</button>
</div>
div{background-color: rebeccapurple;width:200px;height:50px;border:1px solid black;overflow:hidden}
p{color: white;width: 202px;margin-left: -1px;text-align: center;white-space:nowrap;}