forked from ML-Fusion-Lab/ML-Fusion-Lab-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visi.js
29 lines (18 loc) · 717 Bytes
/
visi.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
// Function to get the count from localStorage or initialize it
function getVisitorCount() {
return localStorage.getItem('visitorCount') || 0;
}
// Function to increment and save the count
function incrementVisitorCount() {
let count = parseInt(getVisitorCount()) + 1;
localStorage.setItem('visitorCount', count);
return count;
}
// Function to display the count
function displayVisitorCount() {
const counterElement = document.querySelector('.website-counter');
const count = incrementVisitorCount();
counterElement.textContent = count;
}
// Call the display function when the page loads
document.addEventListener('DOMContentLoaded', displayVisitorCount);