Suppose we choose the element var $el = $('.hi'); . so why not remove the class from this element? I do this - $el.removeClass('hi'); but zero reactions. Errors in the console does not issue. Maybe the browser is to blame? I use firefox de

 $hi = $('.hi'); $hi = removeClass('hi'); (!$hi.hasClass('hi')) ? $hi.html('Удален') : $hi.html('Не удален'); 
 <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <div class="hi">Пример</div> 

  • one
    Most likely the developer is to blame. It would be great if you wrote what reaction you expect. They also brought [a] not a working example, demonstrating problematic behavior. - Igor
  • "Run code" button - click. Explanations required? - Igor
  • I think explanations are required. - Ilya Balabuev
  • See the answer below - Igor

2 answers 2

Let's try to replace the line $hi = removeClass('hi'); on $hi.removeClass('hi');

 $hi = $('.hi'); $hi.removeClass('hi'); (!$hi.hasClass('hi')) ? $hi.html('Удален') : $hi.html('Не удален'); 
 <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <div class="hi">Пример</div> 

  • oh lord how embarrassing. Sorry for such nonsense D: - Ilya Balabuev
  • one
    @ IlyaBalabuev Don't worry :) - so much. Everyone once started. - Igor
  • that's for sure ...... - Air

 var div = document.querySelector('.div'); console.log(document.querySelector('#menu')); setTimeout(function() { div.classList.remove('div'); console.log(document.querySelector('#menu')); }, 2222) 
 <div id="menu" class="div"></div>