1. 首页
  2. 数据库
  3. JavaScript中点击事件的写法

JavaScript中点击事件的写法

上传者: 2020-11-26 20:29:40上传 PDF文件 23.47KB 热度 24次
<button id="btn">click</button> var btn=document.getElementById('btn'); 第一种: btn.onclick=function(){ alert('hello world'); } 消除事件:btn.onclick=null;//就不会弹出框了 第二种: btn.addEventListener('click',function(){alert('hello world')},false); btn.addEventListener('click',functi
下载地址
用户评论