Omar Omar - 2 years ago 79
Javascript Question

On button click fade div in, otherwise fade in after x seconds

I'm trying to fade in a div after x seconds, but if a button is clicked, fade in right away or make the delay sooner. However, the button click is not overriding the default.

$(document).ready(function() {

$("#skipIntroBTN").click(function() {

Answer Source

You could use setTimeout here

var fade = function() {
$('button').click(function() {

setTimeout(fade, 12000);
div {
  height: 50px;
  width: 50px;
  background: black;
  display: none;
<script src=""></script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download