Karthik Amar
Karthik Amar

Reputation: 217

how to hide an element after the fade out time

Say I have img element:

  <img id='someimage'>

  <script>
      $('#someimage').fadeOut(3000);
      $('#someimage').hide();
  </script>

I want to hide instruction to get executed only after the fadeOut time is over.

Upvotes: 4

Views: 1338

Answers (1)

Jazi
Jazi

Reputation: 6732

You should just check jQuery documentation ;) [LINK]. Use callback as the second argument of fadeOut() function.

Code:

<script>
    $('#someimage').fadeOut(3000, function() {
        $(this).hide();
    });
</script>

But, for the record, fadeOut() function will hide particular element anyway. There is no need to use hide() additionally for img#someimage.

Upvotes: 8

Related Questions