CSS Question

Why doesn't work my JS to remove a class?

I can't understand why my js code to remove a class when the screen is smaller than 992px doesn't work. Could someone help me please? I would like to remove the class called "w60"

I was reading some post but I can't find where is my mistake.



$(window).resize(function(){
If($(window).width()<992){
$('#presentation').removeClass('w60');
}
});

.w60 {width:60% !important}

<div id="presentation" class="col-md-7 w60">
<p class="pre_h3">Hello there!</p>
</div>




Answer

Try Following, Hope it will works for you

$(window).resize(function(){
  alert($(window).width());
 if($(window).width()<992){
  $('#presentation').removeClass('w60');
 }
}).resize(); 
.w60 {width:60% !important}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="presentation" class="col-md-7 w60">
<p class="pre_h3">Hello there!</p>
</div>