浏览模式: 普通 | 列表
4月, 2024 | 1
如果使用!important在你的样式中,比如display: none !important,此时就不能用show()了

但是我在查阅资料时发现有这样的解释,
If using !important in your styles, such as display: none !important, it is necessary to override the style using .css('display', 'block !important') should you wish for .show() to function correctly.


这其实是不对的(也许是因为jquery版本不同的原因)

我查了下官方文档并测试了下,应该是这样:
第一种方法,直接设置style,不能用.css()和.prop()
$("#a1").attr("style","display:block !important");
...

阅读全文…
1