I have the following code. I want to add a button as a child of another element named element.
//parent div
const element = document.getElementById("idClass")
const button = document.createElement("button")
button.textContent = "Click me"
element.appendChild("button")
Can someone tell me why it doesn't work ?