sagar kodte sagar kodte - 5 months ago 7
jQuery Question

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"
});
});
});

Answer

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);
  });
});
Comments