如果CSS规则发生变化,浏览器是否需要刷新
如果我通过 javascript 更改了 CSS 规则,是否需要执行任何操作来“刷新”浏览器以使用更新后的规则重新显示当前页面?
If I have changed a CSS rule via javascript, do I need to do anything to "refresh" the browser to redisplay the current page using the updated rules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不——刷新不是必需的——如果确实发生了,它会将文档恢复到其原始状态。
更改应立即发生(例如,设置显示:无)。 使用 FireFox 插件 FireBug (http://getfirebug.com/) 或 IE 开发工具栏(内置于 IE8 中并可用)作为以前版本的免费插件)来动态查看 HTML,以确保您认为正在发生的更改确实发生。
No--a refresh isn't necessary--and if it did occur it would restore the document to its original state.
The change should take place immediately (setting display: none, for example). Use FireFox plugin FireBug (http://getfirebug.com/) or the IE Developer Toolbar (built into IE8 and available as a free plugin for previous versions) to dynamically view the HTML to ensure the change you think is taking place is actually occurring.
通过 JavaScript 动态更改 CSS 属性应该自动在用户的 Web 浏览器中进行更改,除非您的脚本出现问题或者用户关闭了 JavaScript。
Changing CSS properties on the fly via JavaScript should automatically make the change in the user's web browser unless there is something wrong with your script of if the user has JavaScript turned off.