-
flag 標志變量定義沒搞懂查看全部
-
<!doctype html> <html> <head> <title></title> <meta charset='UTF-8'/> <style type='text/css'> *{ padding:0; margin:0; } #div1{ width:200px; height:100px; background:red; } </style> <script> window.onload=function(){ var oDiv=document.getElementById('div1'); oDiv.onmouseover=function(){ startMove(1000); } oDiv.onmouseout=function(){ startMove(100); } var timer=null; function startMove(iTarget){ clearInterval(timer); timer=setInterval(function(){ var speed=0; if(iTarget>200){ speed=10; }else{ speed=-10; } if(oDiv.offsetWidth==iTarget){ clearInterval(timer); }else{ oDiv.style.width=oDiv.offsetWidth+speed+'px'; } },30); } } </script> </head> <body> <div id='div1'></div> </body> </html>查看全部
-
currentStyle getComputedStyle查看全部
-
.offsetleft獲取當前對象的left屬性值查看全部
-
JSON格式: var json = {name:key,name,key,...} for(var i in json){ alert(i); //遍歷name alert(json[i]); //遍歷key }查看全部
-
鏈式運動需要底層框架查看全部
-
鏈式動畫!在運動函數中用if(cur==target){clearInterval(obj.timer) if(fn){ fn(); } }查看全部
-
1、獲取當前透明度不用parseInt 2、設置透明度要考慮兼容 obj.style.filter='alpha(opacity:'+(當前透明度+變化速度)+')'; obj.style.opacity=(當前透明度+變化速度)/100; 3、透明度不加“px” 在使用parseInt()時處理透明度小數時,會有影響 單位設置 相應位置進行判斷 IE/FireFox 取相應值 Math.round()四舍五入取整數值 Math.round(parseFloat(getStyle(obj,attr))*100)查看全部
-
JSON格式: var json = {name:key,name,key,...} for(var i in json){ alert(i); //遍歷name alert(json[i]); //遍歷key }查看全部
-
添加透明度的時候比較特殊。查看全部
-
添加透明度: filter:alpha(opacity:30); opacity:0.3;查看全部
-
parseInt(getStyle(obj,'width'));查看全部
-
獲取樣式:查看全部
-
獲取樣式兼容性寫法 if(obj.currentStyle){return obj.currentStyle[attr]}else{return getComputedStyle(attr,false)[attr]} offset 做運動計算時存在內外 邊距 或者邊框 影響計算 offsetwidth 不等于width查看全部
-
offsetwidth:是元素相對父元素的偏移寬度。等于border+padding+width 而width僅僅是自身的寬度 獲取樣式,解決兼容性 //obj 節點對象 //attr 屬性名 // function getStyle(obj,attr){ // if (obj.currentStyle) { // return obj.currentStyle[attr]; // } else{ // return getComputedStyle(obj,false)[attr]; // }; // }查看全部
舉報
0/150
提交
取消