开发者

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(){开发者_如何学C
$('.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


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

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜