I am adding a button dynamically in html like below: On click of that button I want to call a Javascript function:
var but = document.createElement(\"button\
This code work good to me and look more simple. Necessary to call a function with specific parameter.
var btn = document.createElement("BUTTON"); // element var t = document.createTextNode("MyButton"); // Create a text node btn.appendChild(t); btn.onclick = function(){myFunction(myparameter)}; document.getElementById("myView").appendChild(btn);//to show on myView