Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How can I get CSS proerties of element with jquery ? Reply To: How can I get CSS proerties of element with jquery ?

#151814
TheDoc
Moderator

I generally try to avoid manipulating the CSS directly with jQuery.

Instead of doing something like this:

$('.element').css({
    border           : '1px solid red',
    background : 'blue
    // etc
});

I’d rather to do this:

$('.element').addClass('something');

And then in your CSS file:

.something {
    border: 1px solid red;
    background: blue;
    /* etc */
}

So instead of getting the CSS properties via jQuery, you should probably be figuring out how to utilize classes.