How to set multiple CSS style using jQuery

In last post, I had explained how to select multiple element in single statement using jQuery. In this post, I will show you how can you set multiple CSS styles to any selector/element in single statement.

Let's say you have a div tag and you want to set its background color to yellow, forecolor to red, font family to arial and font size to 18pt. One way is to write multiple statements like.
But there is another nice way to do this. See below jQuery code.
jQuery provides another nice way to set multiple CSS style together using an object literal. Object literal provides grouping of key/value pair. We can define object literal in curly braces. Key and value pair are defined with the help of colon like Key:Value and multiple keys are separated by comma as defined in above code.
See live Demo and Code
Feel free to contact me for any help related to jQuery. I will gladly help you.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..