I want execute onclick event after the 5 second timer gone and second button enabled.. Here is my code.
<a href="#" id="downloadvideo" onclick="OpenInNewTab();" class="btn btn-primary btn-lg">Download Video</a>
Javascript code
<script>
var towait = 5;
var selector = "#downloadvideo";
function counter() {
if (towait == 0) {
$(selector).text("Start Download");
var srclink = '<?= $url;?>';
$(selector).attr('href', srclink).prop('href', srclink).prop('disabled', false);
return;
}
$(selector).text("Wait " + towait + " s").prop('disabled', true);
towait--;
setTimeout(counter, 1000);
}
$(selector).one('click', function(e) {
counter();
return false;
});
</script>