JavaScript中点击事件的三种写法

<button id="btn">click</button> var btn=document.getElementById('btn'); 第一种:this btn.onclick=function(){ alert('hello world'); } 第二种:code btn.addEventListener('click',function(){alert('hello world
相关文章
相关标签/搜索