Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 299
Karthik Amar Avatar asked Mar 17 '23 05:03

Karthik Amar


1 Answers

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.

like image 109
Jazi Avatar answered Apr 08 '23 09:04

Jazi