How do I insert HTML to a div in a tampermonkey script? I've tried
var htmlll= `
<button>hi</button>
`
document.getElementsByClassName("clasname").innerHTML += htmlll;
Although it keeps saying Uncaught (in promise) TypeError: Cannot read property 'innerHTML' of null
.
I have tried
document.addEventListener("DOMContentLoaded", function(event) {
var htmlll= `
<button>hi</button>
`
document.getElementsByClassName("clasname").innerHTML += htmlll;
});
to counter this error, but it didn't work. It didn't give me an error and it didn't append the html.
Note: I am using vanilla javascript. Please dont answer with jquery solutions.