JQuery.css not recommended in 'production' code

The jQuery documentation makes a note: It is not recommended to use .css () as a setter in release-ready code, but when passing an object to set CSS, CSS properties will comelCased instead of using a hyphen. ''

a) Why is this not recommended for use in release-ready code?

b) "but when passing an object to set CSS, the CSS properties will be camelCased instead of using a hyphen."

So, jQuery will change "font-family" to "fontFamily" inside, or is it just a suggestion made here?

Are there any experienced programmers who can clarify this?

+6
source share
1 answer

Your answer to paragraph a is on the same page that you linked to:

Using CSS classes to style

As a getter, the .css () method is valuable. However, it should generally be avoided as a setter in production-ready code, because in general, it is best to save presentation information from JavaScript code. Instead, write CSS rules for classes that describe various visual states, and then change the class to an element.

+5
source

Source: https://habr.com/ru/post/956904/


All Articles