I’m stuck in a problem.
The onclick property for the button created inside Javascript is not working
Here is my code:
Click here
Reply function:
Click here
Advertisement
Answer
try this
var button = document.createElement('button'); button.className = 'btn btn-outlline-primary'; button.value = 'Reply'; button.setAttribute("onclick", "YOURFUNCTIONNAME()"); div.appendChild(button);
you can give your button an onclick funtion with setAttribute