HTML DOM createElement()

46 views Asked by At

I have code is below :

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
       var btn = document.createElement("BUTTON");
       var t = document.createTextNode("CLICK ME");
       btn.appendChild(t);
       document.body.appendChild(btn);
   }
</script>

When I Click button "Try it" it will created button "Click me", after that I click button "Click me" it will do some function. How can I do that.

0

There are 0 answers