onload事件
Tutorial: DOM实战
Category: JS
Published: 2026-04-07 13:58:26
Views: 20
Likes: 0
Comments: 0
window onload 事件
<!DOCTYPE html>
<html lang="en">
<head>
<script>
window.addEventListener("load", function () {
var btn = document.querySelector("button");
btn.addEventListener("click", function () {
alert("点击我");
});
});
window.addEventListener("load", function () {
alert(22);
});
document.addEventListener("DOMContentLoaded", function () {
alert(33);
});
</script>
</head>
<body>
<button>点击</button>
</body>
</html>