标签:cti interval click java class javascrip element script absolute
HTML
<p>文字</p>
CSS
p{ position: absolute; left: 10px; top: 0; opacity: 1; }
JS
var oP=document.getElementsByTagName("p")[0]; var timer=null; document.onclick=function(){ timer=setInterval(function(){ var top1=parseInt(getStyle(oP,"top"))+10; var left1=parseInt(getStyle(oP,"left"))+10; var opctiy1=getStyle(oP,"opacity")-0.1; if(opctiy1==0){ clearInterval(timer) } oP.style.top=top1+"px"; oP.style.left=left1+"px"; oP.style.opacity=opctiy1; },30) } function getStyle(obj,attr){ if(obj.currentStyle){ return obj.currentStyle(attr); }else{ return getComputedStyle(obj)[attr]; } }
标签:cti interval click java class javascrip element script absolute
原文地址:http://www.cnblogs.com/yangxue72/p/7865183.html