dynamically added radio buttons onclick event not working ?
- by Anil Namde
I am trying following,
1. Get response using Ajax from the users selection which returns me the list of the radio buttons attributes as
2. Once i get the attribute list i am creating the radio buttons using createElement()
3. Then i am attaching the event to the radio button for onclick buttons.
4. Then i add element to the DOM using appedChild
The below is code for adding radio button (for IE)
var radio = '<input ';
radio += 'type ="radio" ';
radio += 'id="' + id + '" ';
radio += 'value="" ';
radio += '/>';
radioButton = document.createElement(radio);
radioButton.onClick = function(){alert('this is test')}
ele.appendChild(radioButton);
ele.innerHTML += 'none' + '<br/>';
Now in all this when i am adding the radio button to the DOM onclick is not working and i don't understand why ?
Thanks all