How do I check if an element is hidden in jQuery?

DWQA QuestionsCategory: JavaHow do I check if an element is hidden in jQuery?
Editor Staff asked 2 months ago

How do I check if an element is hidden in jQuery?

2 Answers
Editor Staff answered 2 months ago

this code might be more suitable:

// Checks CSS content for display:[none|block], ignores visibility:[true|false]
$(element).is(":visible");

// The same works with hidden
$(element).is(":hidden");
Editor Staff answered 2 months ago

You can use the hidden selector:

// Matches all elements that are hidden
$('element:hidden')

And the visible selector:

// Matches all elements that are visible
$('element:visible')