Javascript examples for DOM HTML Element:Input Button
Create handler for Onclick button via Javascript code
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body onload="createButton()"> <script> function createButton(){//from www .ja va2 s . com var newButton = document.createElement("button"); newButton.onclick = function() { document.write('test') }; var textButton = document.createTextNode("new Node"); newButton.appendChild(textButton); document.body.appendChild(newButton); } </script> </body> </html>