Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove background-image from style

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>
like image 303
Pinkie Avatar asked Nov 07 '11 03:11

Pinkie


1 Answers

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.

like image 80
nnnnnn Avatar answered Oct 07 '22 03:10

nnnnnn