-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (40 loc) · 1.82 KB
/
index.js
File metadata and controls
43 lines (40 loc) · 1.82 KB
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
37
38
39
40
41
42
43
const signUpLink = document.querySelector(".signIn");
const mainContent = document.querySelector(".main"); // The container for all sections
const signUpButton = document.querySelector(".sign-up-btn");
const signUpContent = document.querySelector("#sign-up-content");
const bookLink = document.querySelector(".book-link");
const bookContent = document.querySelector('#book-now')
// Hide main content and show sign-up content when "Sign Up" <a> is clicked
signUpLink.addEventListener("click", (event) => {
event.preventDefault(); // Prevent default <a> behavior
signUpContent.style.display = "block";
mainContent.style.display="none";
bookContent.style.display = 'none';
scroll(signUpLink)
});
bookLink.addEventListener("click", (event) => {
event.preventDefault(); // Prevent default <a> behavior
bookContent.style.display = "block";
mainContent.style.display="none";
signUpContent.style.display = "none"
scroll(bookLink)
});
// Show main content when header links are clicked
const headerLinks = document.querySelectorAll("header ul li a"); // Select all header links
headerLinks.forEach(link => {
link.addEventListener("click", (event) => {
event.preventDefault(); // Prevent default <a> // Log which link is clicked
mainContent.style.display='block' // show the main content
signUpContent.style.display= 'none' // show the main content
bookContent.style.display = "none"
scroll(link)
});
});
function scroll(link){
const targetId = link.getAttribute("href").substring(1);// Get the id from href (remove #)
const targetContent = document.querySelector(`#${targetId}`);
if (targetContent) {
console.log('hiii')
// Scroll to the targeted content (optional)
targetContent.scrollIntoView({ behavior: "smooth", block: "start" });
}}