如何更改 HTML 元素样式,然后使用 JS 在 onLoad() 上恢复它?
我遇到了 Lightbox 类型模态窗口无法在 IE 中正常工作的问题。我已确定该问题是由于隐藏图像的样式属性为“显示:无”造成的。这在所有其他浏览器中都可以正常工作。但对于 IE,我需要将 onload 值更改为“display: block”,然后直接返回“display: none”,这将解决问题。
谁能告诉我该怎么做?我需要将此规则应用于“image”类的多个 div。
I have a problem with a Lightbox type modal window not working properly with IE. I have identified the problem as being due to the style attribute of the hidden image as 'display: none'. This works fine in all other browsers. But for IE, I need to change the value onload to 'display: block' and then straight back to 'display: none' which will fix the problem.
Could anyone tell me how I can do this? I need to apply this rule to multiple divs of class 'image'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
的css 中:
在html
jquery 版本
In your css
in your html
jquery version:
你使用任何框架吗?我问是因为这可以更改您放置以下代码的位置。
我不确定这是否适用于 IE,但可能会:
未能将其放入您的正文/文档 onLoad 函数中(如果您没有,请创建一个)。
编辑:修正我可怕的拼写。
are you using any frameworks at all? I ask because this can change the location that you put the following code.
I'm not positive if this works in IE but it may:
Failing that put it in your body/document onLoad function (if you don't have one create one).
Edit: fixing my horribad spelling.