How to change the class of a component in Html using Javascript?

1

I wanted to know how to change the class of an html div in JavaScript

  <div id="showmodal" class="modal fade" id="myModal">

I want to change the name class="modal fade" to "modal fade in" in javascript, thank you for the attention!

    
asked by anonymous 11.04.2018 / 13:38

1 answer

2

Select the element and change the attribute className

document.getElementById('showmodal').className = "modal fade";
    
11.04.2018 / 13:52