3
How to check if an element is visible or hidden in jQuery?
For example, an element can be hidden using .hide()
, visible using .show()
or switch between hidden/visible with .toggle()
.
3
How to check if an element is visible or hidden in jQuery?
For example, an element can be hidden using .hide()
, visible using .show()
or switch between hidden/visible with .toggle()
.
4
Use the selectors :visible:
and :hidden
. [1]
var isVisible = $( "#myDiv" ).is( ":visible" );
var isHidden = $( "#myDiv" ).is( ":hidden" );
In addition, you can use them directly on the selector:
$( "#myDiv:visible" ).animate({
left: "+=200px"
}, "slow" );
[1] http://learn.jquery.com/using-jquery-core/faq/how-do-i-determine-the-state-of-a-toggled-element/
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.