如下的写法,CSS不会生效,html也不会显示style
$(".test").css("color","red !important");
如下写法生效,html会显示:style=“color:red !important”
$(".test").css("cssText","color:red !important");
分析原因:个人理解,!important修饰是整句CSS代码如“color:red”,而在第一种写法中,表述的意思是 color = “red !important”,color没有“red !important”这样的值,所以渲染器直接识别不了,而造成了html中没有style。