John
John

Reputation: 770

change complex background with jquery

i want to change the background-color of an element with jquery from:

background: transparent linear-gradient(#C0B 45%, #C0B) 

into:

background-color:#000;

i tried to remove the background-property with .removeAttr(), but nothing works.

Upvotes: 1

Views: 66

Answers (3)

Ibrahim Khan
Ibrahim Khan

Reputation: 20740

You can do it like below.

$('#element_id').css('background', 'none'); // remove background
$('#element_id').css('background-color', '#000'); // set background color

You can combine two line like below.

$('#element_id').css({'background':'none', 'background-color': '#000'});

Upvotes: 1

John
John

Reputation: 770

i found a way. you have to do it like this:

$(this).css("background","none");

after that you can add your own background-properties.

Upvotes: 1

Kedem
Kedem

Reputation: 274

try $(this).css('background-color', 'red');

Upvotes: -1

Related Questions