I am trying to create a button and append it to HTML in Javascript.
This is my code:
<html>
<head>
<script>
var btn=document.createElement("button");
btn.className = "YourClass";
btn.className += " YourClass2";
btn.id ='someId';
document.getElementById("main").appendChild(btn);
</script>
</head>
<body>
<div id = 'main'>
</div>
</body>
</html>
Unfortunately, this does not work and i don't understand why.