Answer the question
In order to leave comments, you need to log in
How to delay the execution of the script for another time on click?
How to postpone the execution of this script by the same amount by clicking on the button with the class .button
?
function myFeed() {
if(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
(function(w, d, n, s, t) {
w[n] = w[n] || [];
w[n].push(function() {
Ya.Context.AdvManager.render({
blockId: "R-A-9999-9"",
renderTo: "yandex_rtb_R-A-9999-9",
async: true
});
});
t = d.getElementsByTagName("script")[0];
s = d.createElement("script");
s.type = "text/javascript";
s.src = "//an.yandex.ru/system/context.js";
s.async = true;
t.parentNode.insertBefore(s, t);
})(this, this.document, "yandexContextAsyncCallbacks");
}
}
setTimeout(function(){
myFeed();
},5000)
Answer the question
In order to leave comments, you need to log in
let timer = setTimeout(myFeed, 5000); // теперь таймер в переменной
const resetTimer = () => {
clearTimeout(timer);
timer = setTimeout(myFeed, 5e3);
}
[...document.querySelectorAll('button.button')]
.forEach((btn) => btn.addEventListener('click', resetTimer));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question