Sagar Kodte
Sagar Kodte

Reputation: 3815

Set time for applying css in jquery

This is my js code. Actually I want to set time to apply this css. I tried using setTimeout but not working. How to do using setTimeout or anything else. Please help. Thank you

$(document).ready(function() {
  $(".front").click(function() {
    $(".flip-container").css({
      "height": "0px"
    });
  });
});

Upvotes: 0

Views: 39

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115222

Use setTimeout() as follows

$(document).ready(function() {
  $(".front").click(function() {
    setTimeout(function() {
      $(".flip-container").css({
        "height": "0px"
      });
    }, 1000);
  });
});

you can also do it with some animation using animate() method

$(document).ready(function() {
  $(".front").click(function() {
    $(".flip-container").animate({
      "height": "0px"
    }, 1000);
  });
});

Upvotes: 2

Related Questions