版权声明:所有原创文章未经本人同意不得随意转载,谢谢 https://blog.csdn.net/tangcc110/article/details/82534343
就像在html中写style=“”一样一次写一堆,但是给cssText设置后原先的css样式被清掉了,只有最新设置的值;
document.getElementById("id").style.cssText = "font-size:100px!important;width:100px;"
如果要不影响原先设置的css,可以这样写
document.getElementById("id").style.fontSize= "100px"; // 不能加任何!important
兼容性:
chrome , firefox , IE8 IE8+都兼容!