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

Asked

Viewed 1,128 times

1

wanted to know how to change the class of a div html 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 your attention!

1 answer

3


Select the element and change the attribute className

document.getElementById('showmodal').className = "modal fade";
  • was just that :) Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.