jQuery - Making fadeOUt use !important

jQuery - Making fadeOUt use !important

本文关键字:important use fadeOUt Making jQuery      更新时间:2023-09-26

我创建了一个jQuery小部件供其他人嵌入他们的网站上,并且在小部件中,我正在使用一个名为"cleanslate"的css重置样式表:

https://github.com/premasagar/cleanslate

这可以阻止页面样式渗入我的小部件。

问题是我的淡出和淡入不再工作,因为重置样式覆盖了 jQuery 添加的display内联样式。我需要使淡出函数为内联样式添加!important;

有谁知道这是否可能?

提前谢谢。

我想

出了下面的解决方案,希望它能帮助处于相同情况的其他人。

欢迎所有评论/改进:

    jQuery("element").fadeOut("slow", function() {
        jQuery("element").attr("style", "display: none !important");
    });

谢谢