Changing a CSS rule-set from Javascript

前端 未结 8 1001
甜味超标
甜味超标 2020-11-22 04:54

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-

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 05:40

    The APIs for editing stylesheets with JS are, sadly, not consistent across browsers. The YUI Stylesheet Utility attempts to smooth over these differences so you could just use that. You could also look at the source code to figure out how it works if you don't want to use YUI itself.

提交回复
热议问题