I've tried to simplify it, simple enough to make my question clearer. The alert 'I am a boy' didn't popup with even after the addClass has been executed. Here is my code:
$(".first").click(function () {
              var a = $(this).html();
              if (a=='On') {
                   $(this).removeClass('first').unbind().addClass('second');
                  $(this).html('Off');
              }
        });
        $(".second").click(function () {
         alert('I am a boy');
      });<button class="first">On</button> 
     
    