I am trying to make a dynamically button in javascript
var button = document.createElement('input');
button.setAttribute('type', 'submit');
button.setAttribute('ID', 'btnSendMailClone');
button.setAttribute('value', 'Submit');
button.setAttribute('onclick', 'btnSendMail_Click()');
button.setAttribute('form', 'myform');
document.body.appendChild(button);
button.setAttribute("class", "btn btn-primary");
$('#button').addClass('myClass');
$('#btnSendMailClone').css("margin-right", "100px")
$('#btnSendMailClone').css("width", "98");
And by clicking on the event it should come on its click event
function btnSendMail_Click() {
debugger;
}
Button i debug its giving me error on this line
document.body.appendChild(button);
it says unable to get property append child.I am newbie to java script.Pleas guide what i am doing wrong