O
O
ololodff2021-12-27 14:49:39
JavaScript
ololodff, 2021-12-27 14:49:39

Why doesn't the function work in the fancybox 4 window?

$("#dbtn{id}").on("click", function () {
    const fancybox{id} = new Fancybox([{
        dragToClose: false,
          src: "#downloadmodal{id}", 
          type: "inline",
          closeButton: false,
          dragToClose: false,
          autoFocus: false,
      },
    ]);
      let timer; // пока пустая переменная
      let x =10; // стартовое значение обратного отсчета
      function countdown(){  // функция обратного отсчета
        document.getElementById('rocket{id}').innerHTML = x;
        x--; // уменьшаем число на единицу
        if (x<0){
          clearTimeout(timer); // таймер остановится на нуле
         	document.getElementById('rocket{id}').innerHTML = 'pipec{id}';
        }
        else {
          timer = setTimeout(countdown, 1000);
        }
      }
      fancybox{id}.on("done", (fancybox, slide) => {
      	countdown();
    });
  });

There are fancybox4 windows when opening a window the fancybox "done" option should fire the countdown function. but he doesn't want to work

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question