<input id="button1" value="Say" type="button" /> 网页元素里什么也没有 <script> var input1=document.getElementById("but"+"ton1") function sayhello(){ alert("hello!") } input1.onclick=sayhello //事件句柄在代码里加 </script>