如何使用jquery修改css中帶有!important的樣式屬性

字號(hào):


    如何使用jquery修改css中帶有!important的樣式屬性?下面小編就為大家?guī)?lái)一篇使用jquery修改css中帶有!important的樣式屬性方法。希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    <div>使用jquery修改css中帶有!important的樣式屬性</div>
    外部樣式為:
    div.test{
      width:auto !important;
      overflow:auto !important
    }
    通過(guò) $("div.test").css("width","100px");和 $("div.test").css("width","100px !important");是無(wú)效的
    要想修改div的width,可以通過(guò)如下這種方式:
    $("div.test").css("cssText", "width:650px !important;");要想修改多個(gè)屬性,可以這么做:
    $("div.test").css("cssText", "width:650px !important;overflow:hidden !important");
    以上這篇如何使用jquery修改css中帶有!important的樣式屬性就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考