Walrus
Walrus

Reputation: 20444

JQuery get all elements with a certain class and remove a CSS property

I am trying to remove a CSS property from all elements with a certain class. I tried this but it did not work.

$(document).ready(function(){
  $(".TABlink").click(function(){
$('.TABlink').css('background-image','')
}); });

That is supposed to remove a background image from all elements with that class if one of them is clicked. Not working.

Any ideas,

Marvellous

Upvotes: 1

Views: 1917

Answers (3)

shashi009
shashi009

Reputation: 770

Maybe late, but it might be useful for future viewers : I had the same requirement, although with background-color. The following function worked for me fine :

$('.className').css('background-color','white');

I had to mention the new-color ('white'), specifying 'none' didn't work.

Upvotes: 0

Adam Albrecht
Adam Albrecht

Reputation: 6870

$('.TABlink').css('background-image', 'none');

Upvotes: 5

Mārtiņš Briedis
Mārtiņš Briedis

Reputation: 17752

Try this, maybe it doesn't like empty property value:

$(document).ready(function(){
  $(".TABlink").click(function(){
    $('.TABlink').css('background-image','none');
  });
});

Upvotes: 5

Related Questions