SteveLacy SteveLacy - 1 year ago 99
CSS Question

Changing body CSS with a jQuery addClass

I am creating a site with a jQuery gallery, and I have the gallery (similar to lightbox) working well.
My question is, can I create a CSS "body class" that I could call from a jQuery event?
This is what I want:
When someone clicks on the image, the gallery appears. Then the body background becomes black, and shrinks to the size of the browser page, and the mainContent disappears only showing the image.
Is there any way to add a body class to the page when a event occurs? Like:


And the CSS:

.the_new_body_css_look {

body {
/* the colors */
mainContent {
/* the size */

Answer Source

Probably the fastest way to check it would be to try it yourself. The answer is yes you can.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download