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\
try this:
but.onclick = callJavascriptFunction;
or create the button by wrapping it with another element and use innerHTML:
var span = document.createElement('span'); span.innerHTML = '';