add a class to a div with an id javascript

a one liner to add a class name to an element with a specific id, for this to run it seems to need a document ready.

HTML

<button id="Login_Button">Hi Im a Button</button>

Javascript

document.addEventListener("DOMContentLoaded", function(event) { 
  document.getElementById("Login_Button").className += " btn btn-sm btn-outline-success";

});

Other Items in javascript
Page Views

This page has been viewed 256 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹

Random Quote
You want to be the best, you MUST put the long yards in! Nothing comes easy in life so stop wishing and start DOING! So many people would rather bitch and moan than help themselves. Dont be one of those negative drainers, start today, make a small change and keep going forwards with this attitude!
Unknown