greedyzebra
Technical User
Hi,
I'm dynamically creating a button with the following code:
var commentButton = document.createElement("input"
commentButton.type = "button";
And I wish to have the button do something when it is clicked (as you would with most buttons). How can I do this?
I've unsuccessfully tried:
commentButton.onclick = "myFunction()";
commentButton.onClick = "myFunction()";
commentButton.onClick = myFunction();
Thanks!
I'm dynamically creating a button with the following code:
var commentButton = document.createElement("input"
commentButton.type = "button";
And I wish to have the button do something when it is clicked (as you would with most buttons). How can I do this?
I've unsuccessfully tried:
commentButton.onclick = "myFunction()";
commentButton.onClick = "myFunction()";
commentButton.onClick = myFunction();
Thanks!