agulaid
asked on
onClick event not working on appendChild method
Ive written the script below, I dont understand why clicking on the button doesnt call the message function.
<script type="text/javascript">
var numbers= 0;
function addfield() {
var newButton= document.createElement("input");
newButton.ID= "button"+numbers;
newButton.value= "button"+numbers;
newButton.onClick= "message()";
newButton.type="button";
document.getElementById('placeholder').appendChild(newButton);
var increment= ++numbers;
numbers= increment;
}
function message() {
alert("Hello There!!!");
}
</script>
<a href="#" onClick="addfield()" >add</a>
<div id="placeholder">
</div>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<a href="#" onClick="addfield()" >add</a>
to:
<a href="#" onClick="addfield();return
?