<!DOCTYPE html><html><head><meta charset="UTF-8"><title>css樣式</title></head><style>*{margin: 0;padding: 0;}#div1{width: 300px;height: 300px;margin: 0 auto;margin-top: 50px;background: red;border-radius: 10px;border: 10px solid #eee;}</style><script >window.onload=function () {var odiv=document.getElementById('div1');odiv.style.background="yellow";var length=odiv.style.length;alert(length);//0var value=odiv.style.getPropertyValue('background');var value2=odiv.style.removeProperty('border');alert(value2);}</script><body><div id ='div1'></div></body></html>
為什么在JS用Length查看style屬性,結(jié)果為0,用removePerproty移除背景好使,但對(duì)border屬性就不好用了
汾汾學(xué)前端
2016-03-22 10:45:21