更新时间:2023-11-23 09:33:58
var foo = function(){
var button = document.createElement('button');
button.innerHTML = 'click me';
button.onclick = function(){
alert('here be dragons');return false;
};
// where do we want to have the button to appear?
// you can append it to another element just by doing something like
// document.getElementById('foobutton').appendChild(button);
document.body.appendChild(button);
};