js之任意值运动框架

   & lt; ! DOCTYPE  html  PUBLIC “-//W3C//DTD  XHTML  1.0,过渡//EN ", " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "比;   & lt; html  xmlns=" http://www.w3.org/1999/xhtml "比;   & lt; head>   & lt; meta  http-equiv=" - type ",内容=" text/html;, charset=utf - 8”,/比;   & lt; title>任意值运动框架& lt;/title>   & lt; style>   div{宽度:200 px;高度:200 px;背景:红色;浮动:左;边界:10 px  black 固体;保证金:50 px;字体大小:50 px;颜色:黄色;}   # div4{过滤器:α(不透明度:30);不透明度:0.3;}   & lt;/style>   & lt; script>   window=function  () {   var  oDiv1=. getelementbyid (“div1”);   var  oDiv2=. getelementbyid (“div2”);   var  oDiv3=. getelementbyid (“div3”);   var  oDiv4=. getelementbyid (“div4”);   oDiv1.onmouseover=function  () {   StartMove(“宽度”,500);   };   oDiv1.onmouseout=function  () {   StartMove(“宽度”,200);   };   oDiv2.onmouseover=function  () {   StartMove(“高度”,500);   };   oDiv2.onmouseout=function  () {   StartMove(“高度”,100);   };   oDiv3.onmouseover=function  () {   StartMove(“字体大小”,100);   };   oDiv3.onmouseout=function  () {   StartMove(“字体大小”,这50);   };   oDiv4.onmouseover=function  () {   StartMove(“不透明度”,100);   };   oDiv4.onmouseout=function  () {   StartMove(“不透明度”,这30);   };   };   function  getstyle (obj,名称)   {   如果(obj.currentStyle),//针对ie获取   {   return  obj.currentStyle[名字];   }//其他针对非行间样式   {   return  getComputedStyle (obj, null)[名字];   }   };   function  StartMove (obj, ss, itarget)   {      clearInterval (obj.timer);   obj.timer=setInterval (function  () {   var  cur=0;   如果(ss==安煌该鞫取?{   坏蛋=parseFloat (getstyle (obj, ss)) * 100   }   其他的   {   坏蛋=方法(getstyle (obj, ss));   }   var 速度=(itarget-cur)/4;   速度=speed> 0 ? Math.ceil(速度):Math.floor(速度);   如果(itarget-cur==0) {   clearInterval (obj.timer);   }   其他{   如果(ss==安煌该鞫取?   {   obj.style.filter='α(不透明度=' + (cur +速度)+ ')';//通过if - else里的取整解决ie里透明度获取值存在偏差问题   如果((cur +速度)祝辞=30)   {   obj.style.opacity=Math.ceil ((cur +速度))/100;   }   其他的   {   obj.style.opacity=Math.floor ((cur +速度))/100;   }   . getelementbyid (txt1) value=https://www.yisu.com/zixun/cur +速度;   }   其他的   {   obj.style [ss]=cur +速度+“px”;   }   }   }, 30);   };   & lt;/script>   & lt;/head>      & lt; body>   & lt; div  id=癲iv1”比;   变宽& lt;/div>   & lt; div  id=癲iv2”比;   变高& lt;/div>   & lt; div  id=癲iv3”比;   字符变大& lt;/div>   & lt; div  id=癲iv4”比;   & lt; input  id=" txt1 ",类型=拔谋尽??,/比;   & lt;/div>   & lt;/body>   & lt;/html>


js之任意值运动框架