从Javascript更改CSS规则集 [英] Changing a CSS rule-set from Javascript
问题描述
可以动态更改CSS规则集(即,当用户单击窗口小部件时,某些JS将更改CSS规则集)
这个特定的CSS规则集适用于页面上的许多元素(通过类选择器),并且当用户单击窗口小部件时,我想修改它,以使所有具有类的元素改变。
你可以,但是很麻烦。有关如何执行此操作的最佳参考文档是以下文章:全部使用Javascript的Pwn CSS (< a href =https://web.archive.org/web/20130709232042/http://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript =nofollow noreferrer>网络存档链接)。 p>
我设法使它适用于Firefox和IE - 我无法在Chrome中,虽然它似乎支持DOM方法。 a href =http://stackoverflow.com/users/695639/ricosrealm> ricosrealm 报告说它也能在Chrome中使用。
Is it possible to make changes to a CSS rule-set dynamically (i.e. some JS which would change a CSS rule-set when the user clicks a widget)
This particular CSS rule-set is applied to lots of elements (via a class selector) on the page and I want to modify it when the user clicks the widget, so that all the elements having the class change.
You can, but it's rather cumbersome. The best reference on how to do it is the following article: Totally Pwn CSS with Javascript (web archive link).
I managed to get it to work with Firefox and IE - I couldn't in Chrome, though it appears that it supports the DOM methods.ricosrealm reports that it works in Chrome, too.
这篇关于从Javascript更改CSS规则集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!