-
Notifications
You must be signed in to change notification settings - Fork 624
Expand file tree
/
Copy pathhome-tabs.js
More file actions
20 lines (17 loc) · 832 Bytes
/
home-tabs.js
File metadata and controls
20 lines (17 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Modern PHP Homepage Interactions
document.addEventListener('DOMContentLoaded', function() {
// Code demo switcher
const codeButtons = document.querySelectorAll('.code-btn');
const codeDemos = document.querySelectorAll('.code-demo');
codeButtons.forEach(button => {
button.addEventListener('click', function() {
const targetDemo = this.getAttribute('data-demo');
// Remove active class from all buttons and demos
codeButtons.forEach(btn => btn.classList.remove('active'));
codeDemos.forEach(demo => demo.classList.remove('active'));
// Add active class to clicked button and corresponding demo
this.classList.add('active');
document.getElementById(targetDemo + '-demo').classList.add('active');
});
});
});