<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

<style>




</style>


</head>
<body>
  




<button onclick="alert('hello');">提示框1</button>


<button onclick="qqq()">提示框2</button>


<button id="ggg">提示框3</button>

<button id="ddd">提示框4</button>

<script>

//html事件,需给元素设置onclick属性和值
function qqq(){
  alert('hello');
};




//DOM0事件,无法给按钮添加多个点击事件
var ggg = document.getElementById("ggg");

ggg.onclick = function (){
  alert('hello');
};


//DOM2事件,可以给按钮添加多个点击事件
var ddd = document.getElementById("ddd");


ddd.addEventListener("click",function(){

  alert('hello');
  
});







</script>



</body>
</html>