兼容性問題
不知道大家在實踐 時候有沒有遇到這種情況,用setAttribute跟getAttribute設置或者獲取屬性的時候,只能獲取元素內置的屬性,比如title,class,src,href這一類的,如果是style比如color,display等等的屬性,是獲取不了也設置不了的……難道是兼容性?我用的Chrome……
不知道大家在實踐 時候有沒有遇到這種情況,用setAttribute跟getAttribute設置或者獲取屬性的時候,只能獲取元素內置的屬性,比如title,class,src,href這一類的,如果是style比如color,display等等的屬性,是獲取不了也設置不了的……難道是兼容性?我用的Chrome……
2018-01-03
舉報
2018-01-04
因為這里的屬性是指元素的屬性,style,class,title,id等。
color,height等屬于樣式style的屬性。
設置:document.getElementById('p4').style.backgroundColor="red";
獲?。簐ar rgb = document.getElementById('p4').style.backgroundColor;