jQuery - remove class from div

6 points
Created by:

In this article we can see how to dynamically remove one class from div element using jQuery.

Quick solution:


Full code example:

// ONLINE-RUNNER:browser;

<!doctype html>
 <script src=""></script>
   .my-class-1 { border: 2px solid red; padding: 5px; width: 200px; }
   .my-class-2 { background: yellow; }
   $(document).ready(function() {
     $("#my-button").click(function() {
       // HERE:
 <div id="my-element" class="my-class-1 my-class-2">Some text</div>
 <button id="my-button" style="margin-top: 20px;">Remove class</button>


Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.


Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂