Registering jQuery click, first and second click

Is there a way to run two functions similar to this:

$('.myClass').click(
    function() {
        // First click
    },
    function() {
        // Second click
    }
);

I want to use a basic toggle event, but .toggle() has been deprecated.


Try this:

$('.myClass').click(function() {
  var clicks = $(this).data('clicks');
  if (clicks) {
     // odd clicks
  } else {
     // even clicks
  }
  $(this).data("clicks", !clicks);
});

This is based on an already answered question: Alternative to jQuery's .toggle() method that supports eventData?


Or this :

var clicks = 0;

$('.myClass').click(function() {
    if (clicks == 0){
        // first click
    } else{
        // second click
    }
    ++clicks;
});

this I worked for my menu

var SubMenuH = $('.subBoxHederMenu').height();  
var clicks = 0;

        $('.btn-menu').click(function(){
          if(clicks == 0){
            $('.headerMenu').animate({height:SubMenuH});
            clicks++;
            console.log("abierto");
          }else{
            $('.headerMenu').animate({height:"55px"});
            clicks--;
            console.log("cerrado");
          }
          console.log(clicks);
        });