javascript 广告移动特效的实现代码
<!DOCTYPEhtml> <htmllang="en"> <head> <metacharset="UTF-8"> <title>Document</title> <style> .box2{} .box2{width:200px;height:200px;background:red;border-radius:50%;position:relative;} .box3{width:800px;height:500px;border:1pxsolidred;} </style> </head> <body> <buttontype=""id="start">开始</button> <buttontype=""id="stop">停止</button> <divclass="box3"> <divid="box"class="box2"> </div> </div> </body> <scripttype="text/javascript"> varlr=600; vartb=300; vari=0; varj=0; varbox=document.getElementById('box'); varstart=document.getElementById('start'); varstop=document.getElementById('stop'); start.onclick=function(){ start.style.display='none'; stop.style.display='inline'; vartime=setInterval(function(){ box.style.left=i+'px'; box.style.top=j+'px'; if(i>lr){ lr=0; i--; } if(i<=lr){ lr=600; i++; } if(j>tb){ tb=0; j--; } if(j<=tb){ tb=300; j++ } stop.onclick=function(){ clearInterval(time); stop.style.display='none'; start.style.display='inline'; } },5); } </script> </html>
以上就是小编为大家带来的javascript广告移动特效的实现代码全部内容了,希望大家多多支持毛票票~