How would I call

Code:
setTimeout(
        function(){
          
          $('#loading').replaceWith($('#amnt'));
          $('#amnt').show();
          
        },
        5000
      );
to start when I click a button
Code:
<a href="#myModal" role="button" class="btn btn-custom" data-toggle="modal"> Counter</a>