100-project-100-days-website/100_projects/100-background-video-pause-&-play/main.js

17 lines
487 B
JavaScript
Raw Normal View History

2023-06-01 09:33:40 +03:00
const btn = document.querySelector(".btn");
const video = document.querySelector(".background-video");
const fa = document.querySelector(".fa");
btn.addEventListener("click", () => {
if (btn.classList.contains("pause")) {
btn.classList.remove("pause");
video.play();
fa.classList.add("fa-pause");
fa.classList.remove("fa-play");
} else {
btn.classList.add("pause");
video.pause();
fa.classList.remove("fa-pause");
fa.classList.add("fa-play");
}
});