mardi 2 janvier 2018

Create a button in javascript with onclick event in IE [duplicate]

This question already has an answer here:

I am trying to make a javascript button so that when it's pressed it deletes the content of the page. I figured it out how to make it in Chrome, but in IE 8 it does not work.

   function button(){
    var btn = document.createElement('button');
    btn.innerHTML = 'Back';
    if(btn.addEventListener)
    btn.addEventListener('click',function(){
    document.body.style.display="none";});
    document.body.appendChild(btn);}




Aucun commentaire:

Enregistrer un commentaire