Javascript-DOM EventListener 事件添加句柄

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>4. Javascript-DOM EventListener 事件添加句柄</title>
</head>
<body>
<button id="btn">按钮</button>
<script>
var x=document.getElementById("btn");
x.addEventListener("click",hello);
x.addEventListener("click",world);
function hello(){
    alert("hello");
}
function world(){
    alert("world");
}
</script>
</body>
</html>
阅读 24

Comments