11

I want to check whether a div with a CSS class="x" has height="auto"

If yes I want (with a jQuery script) the css-class="a" removed from all elements with the css-class="y"

If not the script does not have to do anything. Thanks

Bùi Đức Khánh
  • 3,975
  • 6
  • 27
  • 43
andrej
  • 255
  • 2
  • 3
  • 11

2 Answers2

30
if ($('div.x').css('height') === 'auto') {
    $('.y').removeClass('a');
}
Ken Browning
  • 28,693
  • 6
  • 56
  • 68
7
$(document).ready(function(){
  if ($('div.x').css('height') === 'auto') {
    $('.y').removeClass('a');
  }   

});

You may need to do that within a each() call

AutomatedTester
  • 22,188
  • 7
  • 49
  • 62