<input id="btn2" value="点击" type="button">
<script>
function(){
var btn2=document.getElementById('btn2');
btn2.onclick=function()
{
alert('hello world');
}
}
</script>
怎么点击不弹出,哪里出错了 ???????????
<script> function(){ // 你把这个去掉 写这个 里面的都成“私有”了 外面访问不到。 var btn2=document.getElementById('btn2'); btn2.onclick=function() { alert('hello world'); } } </script>