JavaScript CSS how to add and remove multiple CSS classes to an element

Tags: javascript,html,css,class,append

Problem :

How can assign multiple css classes to an html element through javascript without using any libraries?

Solution :

Try doing this...

document.getElementById("MyElement").className += " MyClass";

Got this here...

    CSS Howto..

    how to use text-indent only with element not ont it's :before Selector?

    How to wrap text in table cell at hyphen?

    how to make div fixed at a particular scroll level

    How to make a photo collage using html and css? [closed]

    How to edit CSS style of a div using C# in .NET

    CSS: how to make a DIV with display: table-celll extend 100% in width

    Css When having 2 bg-image, how to have 1 to extend out of the grid

    How to compile or convert sass / scss to css with node-sass (no Ruby)?

    Show popup after page load

    How/where to center Items on Webpage

    How to show Div after a Specific time of page load?

    Show/Hide tr elements based on multiple CSS classes and input from multiple checkboxes

    How to make a child div alone responsive using css?

    How to Validate HTML, CSS and JS in Eclipse IDE

    How to modify this JQuery CSS into my view?

    Show/Hide function between JS, CSS, and HTML

    How to make a background with 2 gradients in CSS

    How do I make these buttons stay activated after clicking on them?

    How to keep images locked at specific height within Bootstrap container

    How can I slide the sidebar out of view and make the content flexbox resize to fill the void?

    How to display html with css stylesheet in TextView?

    How can I absolutely position a related image_tag?

    how to overlap two div in css?

    How to make a CSS Menu “Selected” with Hover Image Gallery Effect?

    How to properly align rows with bootstrap

    Remove oval border-radius when 2 digit numbers show up

    How to define different css based on element changing number

    How to do such layout with html+css?

    How do I change the :-moz-placeholder color with jQuery once it's set?

    How do I let a div fill in the blank space