100-project-100-days-website/100_projects/100-background-video-pause-&-play/main.js
2023-06-01 09:33:40 +03:00
Ask

17 lines
487 B
JavaScript

{cf8e01c75a36cdb3de68c858259df2ea721c3d92 true 487 main.js 0xc002aa3ea0}

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");
}
});