Skip to content Skip to sidebar Skip to footer

Jquery Show Button After 5 Second

So I got this button that I need to show after 5 second. I have no experience in jquery or javascript HTML Code

You need to wait 0 before you can proceed

Solution 1:

Use setTimeout() to run a function after a time delay:

$(document).ready(function() {
  setTimeout(function() {
    $("#proceed").show();
  }, 5000);
});
#proceed {
  display: none;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><p>You need to wait 0 before you can proceed</p><buttontype="button"id="proceed">proceed</button>

Solution 2:

If you don't want to use jQuery, then use the setTimeOut method as answered by others.

<head><scripttype="text/javascript"src="//code.jquery.com/jquery-1.10.2.js"></script><scripttype="text/javascript">
  $('#proceed').delay(5000).show(0);   
</script></head><body><p>You need to wait 0 before you can proceed</p><buttontype="button"id="proceed"style="display: none;">proceed</button></body>

Solution 3:

If you want to display timer setInterval can be used.

var i = 4;
var time = $("#time")
var timer = setInterval(function() {
  time.html(i);
  if (i == 0) {
    $("#proceed").show();
    clearInterval(timer);

  }
  i--;
}, 1000)
#proceed {
  display: none;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><p>You need to wait <spanid="time">5</span> before you can proceed</p><buttontype="button"id="proceed">proceed</button>

Solution 4:

The easiest way to postpone a function is:

setTimeOut(function(){
         //put your code here.
    },5000)//5000 millisecond

Solution 5:

Try this out. .hide() will hide the button after the page loads. .delay(5000) will wait 5000 milliseconds. Then .show(0) will run after that, showing the button.

$('#proceed').hide().delay(5000).show(0);

Post a Comment for "Jquery Show Button After 5 Second"