I have different videos among each other and would like to show the caption at a certain scrollposition. Is that possible? How can I implent that?
I already have kind of a code snipet
const bodyTag = document.querySelector("body")
const sections = document.querySelectorAll("section")
const clientTag = document.querySelector("div.client")
const headerTag = document.querySelector("header")
document.addEventListener("scroll", function () {
const pixels = window.pageYOffset
sections.forEach(section => {
if (section.offsetTop - 60 <= pixels) {
const title = document.querySelector("div.title")
// clientTag.innerHTML = section.getAttribute("data-client")
clientTag.innerHTML = section.getAttribute("data-client")
}
})
})