What is the difference between click in
document.getElementById("myBtn").addEventListener("click", displayDate);
and onclick in
<!DOCTYPE html>
<html>
<body>
<h1 onclick="this.innerHTML='Ooops!'">Click on this text!</h1>
</body>
</html>
Are they both considered as events? Why can't we use click instead of onclick and visce versa?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…