# Add Class and Remove Class | Snippets | kirupa.com

**URL:** <https://forum.kirupa.com/t/add-class-and-remove-class-snippets-kirupa-com/352331>\
**Category:** programming\
**Created:** [November 23, 2014, 5:14am UTC](https://forum.kirupa.com/t/add-class-and-remove-class-snippets-kirupa-com/352331 "2014-11-23T05:14:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [November 23, 2014, 5:14am UTC](https://forum.kirupa.com/t/add-class-and-remove-class-snippets-kirupa-com/352331/1 "2014-11-23T05:14:45Z")

</div>

by [kirupa](http://www.kirupa.com/me/index.htm) | 16 October 2012

You will often run into situations where you want to alter the look of something using JavaScript. The look of this "something" is often declared using CSS. Instead of debating between using JavaScript or CSS, you can actually do both as described in my [Changing CSS Using JavaScript tutorial](http://www.kirupa.com/html5/changing_css_using_javascript.htm) by fiddling with an element's class value.

* * *
This is a companion discussion topic for the original entry at [http://www.kirupa.com/snippets/add\_class\_and\_remove\_class\_snippet.htm](http://www.kirupa.com/snippets/add_class_and_remove_class_snippet.htm)
