« A Few Links for You | Main | Designing Landing Pages »
Tuesday
Jan112011

Applying CSS with jQuery

Here is the correct way to apply multiple CSS rules with one call to the .CSS() wrapper method. Note the JavaScript-style syntax for the normally dashed properties (font-weight becomes fontWeight and font-style becomes fontStyle). I've broken the statement across multiple lines for readability.

$("

Hi there!

") .css({color: 'red', fontWeight: "bold", fontStyle: "italic"}) .insertAfter("#followMe");