Skip to content

Commit

Permalink
Create script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jjwwcc authored Aug 28, 2024
1 parent 5b3793b commit 61a06f4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cd/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 倒计时功能
function updateCountdown() {
const targetDate = new Date('2027-10-15');
const today = new Date();
const timeDifference = targetDate - today;
const daysRemaining = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));

document.getElementById('countdown').textContent = `距离大学申请截止日还有 ${daysRemaining} 天`;
}

// 进度条功能
function updateProgress(id, valueId) {
const range = document.getElementById(id);
const valueDisplay = document.getElementById(valueId);

range.addEventListener('input', function () {
valueDisplay.textContent = `${range.value}%`;
localStorage.setItem(id, range.value);
});

const storedValue = localStorage.getItem(id);
if (storedValue) {
range.value = storedValue;
valueDisplay.textContent = `${storedValue}%`;
}
}

document.addEventListener('DOMContentLoaded', function() {
updateCountdown();
updateProgress('activity1', 'value1');
updateProgress('activity2', 'value2');
updateProgress('activity3', 'value3');
});

0 comments on commit 61a06f4

Please sign in to comment.