blob: ec6a2838036d02c7cedb6d720b7b3f38e3bc3d48 (
plain)
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
|
// JavaScript to trigger scroll-based animations
window.addEventListener("scroll", function () {
const elements = document.querySelectorAll(".hero-section, .features, .courses, .testimonials, .contact-section");
elements.forEach(function (element) {
if (element.getBoundingClientRect().top < window.innerHeight) {
element.classList.add("visible");
}
});
});
document.addEventListener("DOMContentLoaded", function() {
const faqItems = document.querySelectorAll(".faq-item");
faqItems.forEach(item => {
item.querySelector(".faq-question").addEventListener("click", () => {
item.classList.toggle("active");
});
});
});
// Get the button
const scrollToTopButton = document.getElementById("scroll-to-top");
// When the user scrolls down 100px from the top of the document, show the button
window.onscroll = function() {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
scrollToTopButton.style.display = "block";
} else {
scrollToTopButton.style.display = "none";
}
};
// When the user clicks on the button, scroll to the top of the document
scrollToTopButton.addEventListener("click", function() {
window.scrollTo({
top: 0,
behavior: "smooth" // Smooth scroll effect
});
});
|