Possible Duplicate:
Testing if something is hidden with jQuery
In jQuery, suppose you have an element of some kind that you're hiding and showing, using .hide()
, .show()
or .toggle()
. How do you test to see if that element is currently hidden or visible on the screen?
To check if an element is hidden or not, jQuery :hidden selector can be used. .toggle() function is used to toggle the visibility of an element.
The :visible selector in jQuery is used to select every element which is currently visible. It works upon the visible elements. The elements that are consuming space in the document are considered visible elements. The height and width of visible elements are larger than 0.
You can use .is(':visible') selects all elements that are visible.
Try
$("some-selector").is(':hidden');
or
$("some-selector").is(':visible');
Here are the docs for the :visible
and the :hidden
selectors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With