oDiv.style.background='blue'; //执行时间:0.105ms左右 ↓替换成
oDiv.style.backgroundColor='blue'; //执行时间:0.083ms左右 例①的代码已经很明显的说明综合属性在设置时的区别 例②:div的内联样式为background:0 0 no-repeat #77cc00; js: oDiv.style.background='blue'; //执行时间:0.149ms左右 ↓替换成 oDiv.style.backgroundColor='blue'; //执行时间:0.203ms左右 例②说明在把综合的background替换成backgroundColor会在background:0 0 no-repeat #77cc00里搜索到他的颜色值加以替换,这样会比较费劲。为什么是搜索后替换background的颜色值而不是把background整个代替掉呢? 例③:<div id="div" ></div>oDiv.style.backgroundColor='blue'; alert(oDiv.style.backgroundPosition); //10px 10px
转载于:https://www.cnblogs.com/yomtaaa/p/4417730.html
