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
Post a Comment