<div class="test">使用jquery修改css中带有!important的样式属性</div>

外部样式为:

div.test{
  width:auto !important;
  overflow:auto !important
}

通过 $("div.test").css("width","100px");和 $("div.test").css("width","100px !important");是无效的

要想修改div的width,可以通过如下这种方式:

$("div.test").css("cssText", "width:650px !important;");要想修改多个属性,可以这么做:

$("div.test").css("cssText", "width:650px !important;overflow:hidden !important");

以上这篇如何使用jquery修改css中带有!important的样式属性就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

点赞(96)

评论列表共有 0 条评论

立即
投稿
返回
顶部