Dynamically Changing an Injected CSS Class …Good? …Bad?

后端 未结 1 1301
猫巷女王i
猫巷女王i 2021-01-26 21:16

Dynamically Changing an Injected CSS Class ...Good? ...Bad?

I found a \'need\' to modify a CSS Class that I inject into the header vis javascript. Bec

1条回答
  •  醉话见心
    2021-01-26 21:41

    This is a bad practice. A CSS class should have a single definition. Modifying the class conditionally makes your code hard to follow and hard to maintain.

    The correct way would to be create a separate CSS class for each condition, or modify the DOM directly using Javascript.

    0 讨论(0)
提交回复
热议问题