I have some code that dynamically creates a new button through JavaScript that when clicked calls a JavaScript function. The code works just as expected in Firefox, Chrome, Opera but low and behold, it doesn't work in IE(7 - I'm not even going to bother with IE6).
The button gets created and appears, but it's not calling the onclick event.
var newButton = document.createElement('input');
newButton.setAttribute('id','btnChat_');
newButton.setAttribute('type','button');
newButton.setAttribute('onclick','askQuestion()');
newButton.setAttribute('value', 'Respond');
document.getElementById('frmChat').appendChild(newButton);
Does anyone know why this won't work in IE, or have a suggestion as to how I could write this code so it will work?
Thanks.