<button >这是一个按钮</button>

1 第一添加事件方法

function tex(){

  console.log("2222222222222");

}

2,第二种添加事件方法

var objbtn=document.getElementById("btn");

objbtn.onclick=function(e){

   console.log(3333333333333);

}

3,第三种事件方法

var objbtn=document.getElementById("btn");

objbtn.addEventListener('click',funtion(){

console.log("555555555555555");

})

文章来自 www.96net.com.cn

相关文章:

  • 2021-11-05
  • 2022-12-23
  • 2021-12-11
  • 2021-12-15
  • 2021-12-30
  • 2022-12-23
  • 2022-03-06
  • 2021-06-14
猜你喜欢
  • 2022-12-23
  • 2021-07-01
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案