Haroldo Haroldo - 10 months ago 87
jQuery Question

Is it possible to remove inline styles with jQuery?

A jQuery plugin is applying an inline style (

). I'm feeling lazy and want to override it with

What's the best (lazy) way?


You can simply set it to blank:

$('#element').css('display', '');

and it'll automatically be removed for you.

Here's a quote from the docs:

Setting the value of a style property to an empty string — e.g. $('#mydiv').css('color', '') — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or <style> element.

I don't think jQuery is doing any magic here; it seems the style object does this natively.