• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / CSS / Remove a class from HTML element

Remove a class from HTML element

Remove class from HTML element

Use Element.classList and DOMTokenList.remove() to remove the specified class from the element.

const removeClass = (el, className) => el.classList.remove(className);

// EXAMPLE
removeClass(document.querySelector('p.special'), 'special');
// The paragraph will not have the 'special' class anymore

Source

https://www.30secondsofcode.org/js/s/remove-class

CSS

Related Snippets:

  • Create a custom scrollbar
  • Get and set inline styles for an element
  • Get the computed style of an element
  • Get the default value of a CSS property with JavaScript

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers