D
D
Dmitry2018-01-26 22:33:35
JavaScript
Dmitry, 2018-01-26 22:33:35

How to add onclick to jquery event?

There is such an event:

jQuery(document).ready(function($) {
  init();
    $(document).on('click', '.box', function(event) {
        $('.box').addClass('active')
        setTimeout(function() {
            $('.box').removeClass('active')
        }, 2500);
    });
});

When the button is clicked, some action occurs (except that the active class is added for a while). How to make it so that, when clicked, the target is also fixed in Yandex.Metrica? I know to add onclick="yaCounterXXX.reachGoal('press-me'); return true;", but how do I add it to this code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2018-01-26
@d9d9_Sun

It's just a function. Just add her challenge

$(document).on('click', '.box', function(event) {
        yaCounterXXX.reachGoal('press-me'); 
        $('.box').addClass('active');
        ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question