Home > Article > Web Front-end > js operation css implementation code_javascript skills
When what we need is a rule, we cannot perform this operation every time the DOM changes, otherwise it will be too inefficient.
Fortunately, the css rules in the dom can also be modified. However, different browsers have different interface descriptions for CSS rules. IE uses a hash table-like method, while FF uses an array.
In terms of programmability, the interface description of ie is more popular with programmers, but logically, ff is obviously more reasonable.
I provide a simple packaging of the two sets of codes in a way similar to IE, but IE cannot be sure to honor the rules synchronously after the css removeRule of the dom. So it's better to use rule override instead of remove.
It should be noted that when using the js function, there must be at least one style tag on the page. Below is the code and examples.