KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am adding a button dynamically to HTML as shown below. When clicking that button I want to call a JavaScript function. var but = document.createElement("button"); but.value="delete row"; but.setAttribute("onclick","callJavaScriptFunction()"); // this is not working but.onclick="callJavaScriptFunction()" // this is also not working document.getElementById("but").onclick="callJavaScriptFunction()" // this is also not working but.id="but"+inc; How can this be resolved?
Tags (comma-separated)
Save Edits
Cancel