• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / JavaScript / JavaScript toggle add class / remove class

JavaScript toggle add class / remove class

If You have multiple elements and do You want to set an active class only the clicked item. You can control with this snippet for instance a size selector on a webshop’s product page.

If You have only one element and do You want to control a menu dropdown toggle:

Method 1

Method 2

HTML

Method 3

Filed Under: JavaScript

About Gabor Flamich

I'm a web developer and designer based in Budapest, Hungary. In recent years, I've documented hundreds of solutions I came across during development. This site is an archive for useful code snippets on WordPress, Genesis Framework and WooCommerce. If You have any questions related to WordPress development, get in touch!

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved