< > <script type="text/javascript"> window.onload = function(){ var btn = document.createElement('input'); btn.setAttribute('type','button'); btn.setAttribute('value','button1'); btn.attachEvent("onclick",function(e){ alert("button1 events"); }) document.body.appendChild(btn); } 《script》