<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test addEventListener</title>
</head>
<body>
<button id="myBtn">click me</button>
<p id="demo">
<script>
document.getElementById("myBtn").addEventListener("click", onClick);
function onClick()
{
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
</body>
</html>
标签:8.1,js,getElementById,onClick,addEventListener,div
From: https://www.cnblogs.com/pansidong/p/17291810.html