How can I call JavaScript function after the whole web page loaded?

47 Views Asked by At

I have JavaScript function , I want to run this function when webpage is completely loaded, But it's not working. here is my code

window.onload = function() {
var btn = document.getElementsByClassName('title');
for (var i = 0; i < btn.length; i++) {
    btn[i].insertAdjacentHTML('afterend', `
          <div> <button class= "btn">
                <img src="logo.png" height="20px" width="70px">
             </button>
          </div>
        `);
    }
}
0

There are 0 best solutions below