Skip to content

Commit 6708a6e

Browse files
committed
添加彩蛋
添加彩蛋,完成 #9
1 parent b94a826 commit 6708a6e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<body>
1010
<div class="container">
1111
<img id="mainImage" src="images/heart.png" alt="爱心">
12-
<h1 id="question">可以成为我的恋人吗</h1>
12+
<h1 id="question"><a id="egg">可以</a>成为我的恋人吗</h1>
1313
<div class="buttons">
1414
<button id="yes">可以</button>
1515
<button id="no">不要</button>
@@ -18,4 +18,4 @@ <h1 id="question">可以成为我的恋人吗?</h1>
1818

1919
<script src="script.js"></script>
2020
</body>
21-
</html>
21+
</html>

script.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let yesButton = document.getElementById("yes");
22
let noButton = document.getElementById("no");
3+
let eggButton = document.getElementById("egg");
34
let questionText = document.getElementById("question");
45
let mainImage = document.getElementById("mainImage");
56

@@ -61,7 +62,7 @@ const loveTest = `!!!喜欢你!! ( >᎑<)♡︎ᐝ ${
6162
username ? `${safeUsername} ♡︎ᐝ(>᎑< )` : ""
6263
}`;
6364

64-
yesButton.addEventListener("click", function () {
65+
function ok() {
6566
// 先创建基础 HTML 结构
6667
document.body.innerHTML = `
6768
<div class="yes-screen">
@@ -75,4 +76,7 @@ yesButton.addEventListener("click", function () {
7576

7677
// 禁止滚动,保持页面美观
7778
document.body.style.overflow = "hidden";
78-
});
79+
};
80+
81+
yesButton.addEventListener("click", ok);
82+
eggButton.addEventListener("click", ok);

0 commit comments

Comments
 (0)