修改important样式

有important的样式修改起来有点头疼,样式比js里的优先级还高,修改样式加important发现无效,样式并没有修改

.a {
    top: 0;
    right: 0;
    position: fixed;
    z-index: 3001 !important;
    overflow: auto;
    margin: 0
}
<div class="a">index</div>

然后发现div的层级太高了,想改掉

document.getElementsByClassName("a")[0].style.zIndex = 100!important;//没有效果
$(".a").css("z-index", "100!important;");//还是没有效果
$(".a").css("cssText", "z-index:100!important;");//这个就可以了
$(".a").css("cssText", "width:650px !important;overflow:hidden !important");//多个
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容