jQuery .css not recommended in 'production' code

后端 未结 1 1833
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 12:47

The jQuery documentation makes a remark, \' It\'s not recommended to use .css() as a setter in production-ready code, but when passing in an object to set CSS, CSS propertie

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 13:38

    Your answer to point a is found on the same page you linked to:

    Using CSS Classes for Styling

    As a getter, the .css() method is valuable. However, it should generally be avoided as a setter in production-ready code, because it's generally best to keep presentational information out of JavaScript code. Instead, write CSS rules for classes that describe the various visual states, and then change the class on the element.

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