使用 js 改变 css(style) 样式

2020-12-10  本文已影响0人  xcyzjs

要改变的是样式表, 如:

<style>
  a.active {
    color: red;
  }
</style>


<script>
  document.styleSheets[0].add('a.active', 'color: blue !important')
<script>

参考cnblog: JS设置CSS样式的几种方式

上一篇 下一篇

猜你喜欢

热点阅读