-
Notifications
You must be signed in to change notification settings - Fork 0
/
obituary.js
36 lines (30 loc) · 1.37 KB
/
obituary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
document.addEventListener("DOMContentLoaded", function() {
// 背景音樂自動播放
const backgroundMusic = document.getElementById('background-music');
if (backgroundMusic) {
backgroundMusic.play().catch(error => {
console.log("音樂自動播放被阻止:", error);
});
}
// 留言板提交功能
const commentForm = document.getElementById('comment-form');
const commentsContainer = document.getElementById('comments-container');
commentForm.addEventListener('submit', function(event) {
event.preventDefault();
const name = document.getElementById('comment-name').value.trim();
const message = document.getElementById('comment-message').value.trim();
if (name && message) {
const newComment = document.createElement('div');
newComment.classList.add('comment');
newComment.innerHTML = `<strong>${name}</strong><p>${message}</p>`;
commentsContainer.appendChild(newComment);
commentForm.reset(); // 重置表單
}
});
// 花籃展示功能
const flowerBasketsButton = document.getElementById('show-flower-baskets');
const flowerBasketGallery = document.getElementById('flower-basket-gallery');
flowerBasketsButton.addEventListener('click', function() {
flowerBasketGallery.style.display = 'flex';
});
});