A
A
Alexander Osadchy2021-06-21 14:33:11
JavaScript
Alexander Osadchy, 2021-06-21 14:33:11

How to track every third jQuery click?

I have a certain block that needs to be updated every third click on the selector - please tell me how to do this?

Here, I found a solution for every second click .. is it possible to cut it somehow? (

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Osadchiy, 2021-06-21
@DELUX

And that's it, I found a solution .. suddenly it will come in handy for someone:

$elem.click((function() {
        var count = 0;
        return function() {
            count++;
            if (count % 3 == 0) {
                alert("Click #" + count);
            }
        }
    })());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question