How can i remove background-image from element style. I don't want to set it to none or 0. I want to remove it completely. it's conflicting with moz-linear-gradient
which is defined in another class.
<div style="background-image:url(http://domain.com/1.jpg); width:100px" class="mozgradient"></div>
Have you tried:
$(".mozgradient").css("background", "");
Setting the background to an empty string should remove the inline style such that class and other stylesheet settings take effect, but it shouldn't affect other styles that were set inline like width
. (In this case removing it from all elements with the mozgradient
class prevents the conflict you are talking about.)
From the jQuery .css() doco:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With