views:

29

answers:

2

In jQuery, fontSize and font-size are both valid in the css() function, but in animate(), it has to be fontSize?

Are there more rules for other functions?

so the safest is still the form fontSize

Update: our project uses jQuery 1.3.1, and it will not work... but I just checked that 1.4.2 will work with "font-size" even for animate.

A: 

in css() function if the property have "-" (such as font-size) you must use " " wrap it

$("p").css({ color: "#ff0011", background: "blue" }); 

$("p").css({ "margin-left": "10px", "background-color": "blue" }); 

in animate() function if the property have "-" you must use CamelCase

e.g. marginLeft replace margin-left

dushouke
All of which is true, but doesn't really relate to the questioner's question. He's clearly aware he has to put font-size in quotes. The question asks about `css` supporting font-size but `animate` not.
T.J. Crowder
+1  A: 

from the .animate() API page:

The .animate() method allows us to create animation effects on any numeric CSS property. The only required parameter is a map of CSS properties. This map is similar to the one that can be sent to the .css() method, except that the range of properties is more restrictive.

cmendoza
The next paragraph defines what they mean by "more restrictive," and it has nothing to do with aliases. It's about numeric properties.
T.J. Crowder
@T.J. Crowder You are correct, after going back and looking at it, it certainly does read that way.
cmendoza