添加:js测试 关闭窗口按钮 打开窗口按钮 运算测试

This commit is contained in:
2025-03-05 11:28:08 +08:00
parent c3d46c329b
commit 86f2e26b4e
3 changed files with 24 additions and 9 deletions
+3 -5
View File
@@ -10,14 +10,12 @@ button {
height: 3em;
color: rgb(255, 255, 255);
background-color: rgb(240, 120, 24);
display: block;
margin: 0 auto;
margin-top: 2em;
}
button:hover {
color: rgb(240, 120, 24);
background-color: rgb(255, 255, 255);
}
#click_button {
display: block;
margin: 16em auto;
}
+3 -1
View File
@@ -8,6 +8,8 @@
<title>js测试</title>
</head>
<body>
<button id="click_button">点我弹窗</button>
<button id="alert_button">点我弹窗</button>
<button id="close_button">点我关闭窗口</button>
<button id="open_button">点我打开窗口</button>
</body>
</html>
+17 -2
View File
@@ -1,7 +1,22 @@
alert('测试');
document.addEventListener("DOMContentLoaded", function () {
const button = document.getElementById("click_button");
button.addEventListener("click", function () {
const alert_button = document.getElementById("alert_button");
alert_button.addEventListener("click", function () {
alert("你还真按啊");
});
const close_button = document.getElementById("close_button");
close_button.addEventListener("click", function () {
window.close();
});
const open_button = document.getElementById("open_button");
open_button.addEventListener("click", function () {
window.open();
});
});
var num1 = 1;
var num2 = 2;
console.log(num1 + num2);