Omar Omar - 1 year ago 38
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>