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
相關文章
相關標籤/搜索