java - In jQuery, how many braces are needed for .css? -


does jquery method .css need div.css({"color":"red"}); or div.css("color":red");?

if there's specific use both of them, please tell me. thanks.

you need format:

div.css('color','red');  

if there 1 setting.

however, perform multiple settings in 1 instruction, must use object:

div.css({'color':'red','background':'yellow'}); 

or, if prefer format:

div.css({     'color':'red',     'background':'yellow' }); 

note:

in first example, comma separates css selector setting. in object, comma separates each pair, , colon separates selector setting.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -