getstyle函數(shù)
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}
else{
return getComputedStyle(obj,false)[attr];
}
}
這個(gè)函數(shù)是不是不能獲取未定義的屬性,例如top,left默認(rèn)是0,沒有設(shè)置
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}
else{
return getComputedStyle(obj,false)[attr];
}
}
這個(gè)函數(shù)是不是不能獲取未定義的屬性,例如top,left默認(rèn)是0,沒有設(shè)置
2016-05-08
舉報(bào)
2016-05-09
如果是border等未定義的屬性,它獲取到的是(0px none rgb(0,0,0))
你說的這個(gè)top,left如果未定義獲取到的是auto
所以應(yīng)該是獲取不到你想要的值 0?
2016-05-10
請問這個(gè)是getStyle函數(shù)是不兼容谷歌嗎,那谷歌瀏覽器要怎么兼容