Question in regards of clearInterval() , .on() and off()

Hi community.

I’ve implemented that method and event handlers on my Pomodoro clock challenge:

https://codepen.io/Sharkantropo/pen/BwBLbj

Although these don’t seem to work as intended.

Firstly, clearInterval()

The timer is mainly handled by the following function. flag variable allows me to recreate the already deprecated toggle().

click_clock.set_countdown= function ()
{
   $("#box > button").click( function (){ 
    if(flag)
      {
          var m=click_clock.sess_time.html();
          var s='00', togg= false;
          $(this).html('reset');
          flag=!flag;
          var timerPomo = setInterval(function()
          {
            if(s == '00')
              {
                m=parseInt(m);
                m--;
                s=60;
              }
              s=parseInt(s);
              s--;
              if(s<10){s='0'+s;}
               $("#box > div").html(m+":"+s);
              if(m == 0 && s == '00')
                {
                  if(!togg)
                    {
                        m=click_clock.break_time.html();
                        togg=!togg;
                    }
                  else
                    {
                        m=click_clock.sess_time.html();
                        togg=!togg;
                    }
                }        
          },1000);
      }
    else
      {
          $(this).html('start'); 
          flag=!flag;
          set_timer.initNset();
          clearInterval(timerPomo); 
      }
  });
}

Now, within the outermost else conditional I have:

else
      {
          $(this).html('start'); 
          flag=!flag;
          set_timer.initNset();
          clearInterval(timerPomo); 
      }

That’s where I currently have major issues. clearInterval() doesn’t stop timerPomo (my setInverval ID) from keep running.

In regards of .on() and off() I just want to know how I could implement them in order to deactivate the buttons with .plus and .minus classes.

Thanks fin advance.

Nevermind. I declare timerPomo as a global scope variable; and now clearInterval works as intended.