visibility - javascript - jquery dom manipulation cheat sheet - How do I check if an element is hidden in jQuery?

jquery create element / javascript / jquery / dom

Is it possible to toggle the visibility of an element, using the functions .hide(), .show() or .toggle()?

Nicolas Gervais



Answer #1
$('#clickme').click(function() {
  $('#book').toggle('slow', function() {
    // Animation complete.
    alert($('#book').is(":visible")); //<--- TRUE if Visible False if Hidden
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="clickme">
  Click here
</div>
<img id="book" src="https://upload.wikimedia.org/wikipedia/commons/8/87/Google_Chrome_icon_%282011%29.png" alt="" width="300"/>