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 properties will be camelCased instead of using a hyphen.'
a) Why is it not recommended to use this in production-ready code?
b) "but when passing in an object to set CSS, CSS properties will be camelCased instead of using a hyphen."
So jQuery will modify "font-family" to "fontFamily" internally, or is this just a suggestion made here?
Are there any experienced programmers that can further clarify this?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With