ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 2.8 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://educationecosystem.com/blog/javascript-check-hidden-element/ |
| Last Crawled | 2026-01-21 00:14:28 (2 months ago) |
| First Indexed | 2022-02-25 14:59:38 (4 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Learn JavaScript - How To Check if An Element is Hidden Using jQuery - LCTV |
| Meta Description | Trying to find hidden elements in HTML documents? Discover how to use jQuery to do that on Education Ecosystem blog. Improve your Javascript skills today. |
| Meta Canonical | null |
| Boilerpipe Text | Â
When we are using jQuery in JavaScript, often we want to take an action based on the state of an element. One that is widely used is if the state of the element is visible or not. An element is visible when if it consumes space in the document. Visible elements have a height or width larger than zero.
To find out if an element is hidden, we basically have two tools to use. The first that we’ll see use is: visible.
Â
JavaScript – using: visible with jQuery
The :visible selector checks whether the element is visible within the DOM.
1
2
3
4
5
6
7
8
9
10
$
(
Document
)
.
ready
(
function
(
)
{
&
nbsp
;
&
nbsp
;
&
nbsp
;
if
(
$
(
"# content"
)
is
(
.
": visible"
)
)
&
nbsp
;
&
nbsp
;
&
nbsp
;
{
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
alert
(
'element is visible in the DOM'
)
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
}
&
nbsp
;
&
nbsp
;
&
nbsp
;
Else
&
nbsp
;
&
nbsp
;
&
nbsp
;
{
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
alert
(
'element is not visible in the DOM'
)
;
&
nbsp
;
&
nbsp
;
&
nbsp
;
}
}
)
;
Below we have an example using this selector to determine an action within the program:
1
2
3
4
5
&
lt
;
Div
id
=
"countries"
&
gt
;
&
nbsp
;
&
lt
;
Div
id
=
"p1"
&
gt
;
US
&
lt
;
/
div
&
gt
;
&
nbsp
;
&
lt
;
Div
style
=
"display: none"
id
=
"p2"
&
gt
;
Canada
&
lt
;
/
div
&
gt
;
&
nbsp
;
&
lt
;
Div
id
=
"p3"
&
gt
;
Mexico
&
lt
;
/
div
&
gt
;
&
lt
;
/
div
&
gt
;
To check if the div #countires is visible, use the is () function with the selector “: visible”:
1
2
3
4
5
if
(
$
(
'# countries'
)
is
(
.
': visible'
)
)
{
&
nbsp
;
// Is visible, do something
Else
&
nbsp
;
// Is not visible, do something
}
Loop the visible divs inside the div #countries:
1
2
3
$
(
"# Div countries: visible"
)
.
Each
(
function
(
)
{
&
nbsp
;
document
.
write
(
$
(
this
)
.
html
(
)
&
nbsp
;
&
nbsp
;
'<br />'
)
;
}
)
;
The result will be:
1
2
USA
Mexico
JavaScript – using: hidden in jQuery
The :hidden selector perform the opposite check of the previous one. It checks if the element is hidden inside the DOM
1
var
isHidden
=
$
(
"#myDiv"
)
.
is
(
": Hidden"
)
;
With these two selectors, you can verify the state of the element and perform something within the code based on the response. Do you know other ways to do this operation in JavaScript? Share your comments in the section below!
If you want to explore other questions,
you can check our videos on JavaScript
. Below are some examples:
RangerSteve.io #gamedev #programming
Developing @GetWhubi
You can also subscribe to some channels that broadcast in JavaScript, such as the following:
ObsidianBlk
Â
TimMikeladze
Another cool way to
find out interesting things about JavaScript is to access our project page
!
4273
About author
I, Dr. Michael J. Garbade is the co-founder of the Education Ecosystem (aka LiveEdu), ex-Amazon, GE, Rebate Networks, Y-combinator. Python, Django, and DevOps Engineer. Serial Entrepreneur. Experienced in raising venture funding.
I speak English and German as mother tongues. I have a Masters in Business Administration and Physics, and a Ph.D. in Venture Capital Financing. Currently, I am the Project Lead on the community project -Nationalcoronalvirus Hotline
I write subject matter expert technical and business articles in leading blogs like Opensource.com, Dzone.com, Cybrary, Businessinsider, Entrepreneur.com, TechinAsia, Coindesk, and Cointelegraph. I am a frequent speaker and panelist at tech and blockchain conferences around the globe. I serve as a start-up mentor at Axel Springer Accelerator, NY Edtech Accelerator, Seedstars, and Learnlaunch Accelerator. I love hackathons and often serve as a technical judge on hackathon panels. |
| Markdown | [](https://educationecosystem.com/blog/)
[Earn](https://educationecosystem.com/create-projects-to-earn-ledu-and-cash)
Menu
- [Viewers](https://educationecosystem.com/blog/category/viewers/)
- [Content Creators](https://educationecosystem.com/blog/category/content-creators/)
- [Businesses](https://educationecosystem.com/blog/category/businesses/)
- [Topics](https://educationecosystem.com/blog/category/topic/)
- [Programming](https://blog.education-ecosystem.com/category/topic/programming/)
- [Design](https://educationecosystem.com/blog/category/design/)
- [Game Development](https://educationecosystem.com/blog/category/topic/game-development/)
- [Artificial Intelligence](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
- [Data Science](https://educationecosystem.com/blog/category/topic/data-science/)
- [Virtual Reality](https://educationecosystem.com/blog/category/virtual-reality/)
- [Blockchain](https://educationecosystem.com/blog/category/topic/blockchain/)
- [Cybersecurity](https://educationecosystem.com/blog/category/topic/cybersecurity/)
- [Creators](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
- [Ledu Token](https://educationecosystem.com/blog/category/topic/ledu-token/)
Menu
- [Viewers](https://educationecosystem.com/blog/category/viewers/)
- [Content Creators](https://educationecosystem.com/blog/category/content-creators/)
- [Businesses](https://educationecosystem.com/blog/category/businesses/)
- [Topics](https://educationecosystem.com/blog/category/topic/)
- [Programming](https://blog.education-ecosystem.com/category/topic/programming/)
- [Design](https://educationecosystem.com/blog/category/design/)
- [Game Development](https://educationecosystem.com/blog/category/topic/game-development/)
- [Artificial Intelligence](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
- [Data Science](https://educationecosystem.com/blog/category/topic/data-science/)
- [Virtual Reality](https://educationecosystem.com/blog/category/virtual-reality/)
- [Blockchain](https://educationecosystem.com/blog/category/topic/blockchain/)
- [Cybersecurity](https://educationecosystem.com/blog/category/topic/cybersecurity/)
- [Creators](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
- [Ledu Token](https://educationecosystem.com/blog/category/topic/ledu-token/)
# Education Ecosystem Blog
The Education Ecosystem Blog is a hub for in-depth development blogs and new technology announcements written by professional software engineers in the Education Ecosystem network
- share
100\.1k shares
## Featured in








- [All Topics](https://educationecosystem.com/blog)
- [LEDU Token](https://educationecosystem.com/blog/category/topic/ledu-token/)
- [Blockchain](https://educationecosystem.com/blog/category/topic/blockchain/)
- [Programming](https://educationecosystem.com/blog/category/topic/programming/)
- [Game Development](https://educationecosystem.com/blog/category/topic/game-development/)
- [Data Science](https://educationecosystem.com/blog/category/topic/data-science/)
- [Cybersecurity](https://educationecosystem.com/blog/category/topic/cybersecurity/)
- [Artificial Intelligence](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
- [Creators](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
[E-Learning](https://educationecosystem.com/blog/category/e-learning/)
# Learn JavaScript – How To Check if An Element is Hidden Using jQuery
September 16, 2016
When we are using jQuery in JavaScript, often we want to take an action based on the state of an element. One that is widely used is if the state of the element is visible or not. An element is visible when if it consumes space in the document. Visible elements have a height or width larger than zero.
To find out if an element is hidden, we basically have two tools to use. The first that we’ll see use is: visible.
### JavaScript – using: visible with jQuery
The :visible selector checks whether the element is visible within the DOM.
\$ (Document) .ready (function () { \ \ \ if (\$ ( "\# content") is (. ": visible")) \ \ \ { \ \ \ \ \ \ \ alert ( 'element is visible in the DOM'); \ \ \ } \ \ \ Else \ \ \ { \ \ \ \ \ \ \ alert ( 'element is not visible in the DOM'); \ \ \ } });
| | |
|---|---|
| 1 2 3 4 5 6 7 8 9 10 | \$ (Document) .ready (function () { if (\$ ( "\# content") is (. ": visible")) { alert ( 'element is visible in the DOM'); } Else { alert ( 'element is not visible in the DOM'); } }); |
Below we have an example using this selector to determine an action within the program:
\<Div id = "countries"\> \ \<Div id = "p1"\> US \</ div\> \ \<Div style = "display: none" id = "p2"\> Canada \</ div\> \ \<Div id = "p3"\> Mexico \</ div\> \</div\>
| | |
|---|---|
| 1 2 3 4 5 | <Div id \= "countries"> <Div id \= "p1"> US </ div> <Div style \= "display: none" id \= "p2"> Canada </ div> <Div id \= "p3"> Mexico </ div> </div> |
To check if the div \#countires is visible, use the is () function with the selector “: visible”:
if (\$ ( '\# countries') is (. ': visible')) { \ // Is visible, do something Else \ // Is not visible, do something }
| | |
|---|---|
| 1 2 3 4 5 | if (\$ ( '\# countries') is (. ': visible')) { // Is visible, do something Else // Is not visible, do something } |
Loop the visible divs inside the div \#countries:
\$ ( "\# Div countries: visible"). Each (function () { \ document.write (\$ (this) .html ()\ \ '\<br /\>'); });
| | |
|---|---|
| 1 2 3 | \$ ( "\# Div countries: visible"). Each (function () { document.write (\$ (this) .html () '\<br /\>'); }); |
The result will be:
USA Mexico
| | |
|---|---|
| 1 2 | USA Mexico |
### JavaScript – using: hidden in jQuery
The :hidden selector perform the opposite check of the previous one. It checks if the element is hidden inside the DOM
var isHidden = \$ ( "\#myDiv" ) .is ( ": Hidden" );
| | |
|---|---|
| 1 | var isHidden \= \$ ( "\#myDiv" ) .is ( ": Hidden" ); |
With these two selectors, you can verify the state of the element and perform something within the code based on the response. Do you know other ways to do this operation in JavaScript? Share your comments in the section below\!
If you want to explore other questions, [you can check our videos on JavaScript](https://www.livecoding.tv/categories/javascript/). Below are some examples:
- - [RangerSteve.io \#gamedev \#programming](https://www.livecoding.tv/michaeljcalkins/videos/EPGO5-rangersteveio-gamedev-programming)
- - [Developing @GetWhubi](https://www.livecoding.tv/kuzzmi/videos/K91GL-developing-getwhubi-reactjs-web-client)
You can also subscribe to some channels that broadcast in JavaScript, such as the following:
[](https://www.livecoding.tv/obsidianblk/)ObsidianBlk
 [TimMikeladze](https://www.livecoding.tv/timmikeladze/)
Another cool way to [find out interesting things about JavaScript is to access our project page](https://www.livecoding.tv/project-discovery/javascript/)\!
[how to check if an element is hidden using jQuery](https://educationecosystem.com/blog/tag/how-to-check-if-an-element-is-hidden-using-jquery/) [how to javascript](https://educationecosystem.com/blog/tag/how-to-javascript/) [javascript](https://educationecosystem.com/blog/tag/javascript/) [javascript and jquery](https://educationecosystem.com/blog/tag/javascript-and-jquery/) [javascript check hidden element](https://educationecosystem.com/blog/tag/javascript-check-hidden-element/) [javascript programming](https://educationecosystem.com/blog/tag/javascript-programming/) [learn javascript online](https://educationecosystem.com/blog/tag/learn-javascript-online/) [programming](https://educationecosystem.com/blog/tag/programming/)
[1](https://educationecosystem.com/blog/javascript-check-hidden-element/#comments)
4273
Share:
[](https://educationecosystem.com/blog/author/livecodingeditor/)
##### About author
### [Dr. Michael J. Garbade](https://educationecosystem.com/blog/author/livecodingeditor/ "Posts by Dr. Michael J. Garbade")
I, Dr. Michael J. Garbade is the co-founder of the Education Ecosystem (aka LiveEdu), ex-Amazon, GE, Rebate Networks, Y-combinator. Python, Django, and DevOps Engineer. Serial Entrepreneur. Experienced in raising venture funding. I speak English and German as mother tongues. I have a Masters in Business Administration and Physics, and a Ph.D. in Venture Capital Financing. Currently, I am the Project Lead on the community project -Nationalcoronalvirus Hotline I write subject matter expert technical and business articles in leading blogs like Opensource.com, Dzone.com, Cybrary, Businessinsider, Entrepreneur.com, TechinAsia, Coindesk, and Cointelegraph. I am a frequent speaker and panelist at tech and blockchain conferences around the globe. I serve as a start-up mentor at Axel Springer Accelerator, NY Edtech Accelerator, Seedstars, and Learnlaunch Accelerator. I love hackathons and often serve as a technical judge on hackathon panels.
[Previous Learn JavaScript – How to Get a Select Value in a Dropdown List?](https://educationecosystem.com/blog/javascript-select-value/)
[Next EconomySim: A Consequence Based Realistic Economy Programmed in Unity by Angryalbino](https://educationecosystem.com/blog/economysim-unty-app/)
- [Viewers](https://educationecosystem.com/blog/category/viewers/)
- [Content Creators](https://educationecosystem.com/blog/category/content-creators/)
- [Businesses](https://educationecosystem.com/blog/category/businesses/)
- [Topics](https://educationecosystem.com/blog/category/topic/)
- [Programming](https://blog.education-ecosystem.com/category/topic/programming/)
- [Design](https://educationecosystem.com/blog/category/design/)
- [Game Development](https://educationecosystem.com/blog/category/topic/game-development/)
- [Artificial Intelligence](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
- [Data Science](https://educationecosystem.com/blog/category/topic/data-science/)
- [Virtual Reality](https://educationecosystem.com/blog/category/virtual-reality/)
- [Blockchain](https://educationecosystem.com/blog/category/topic/blockchain/)
- [Cybersecurity](https://educationecosystem.com/blog/category/topic/cybersecurity/)
- [Creators](https://educationecosystem.com/blog/category/topic/artificial-intelligence/)
- [Ledu Token](https://educationecosystem.com/blog/category/topic/ledu-token/) |
| Readable Markdown | null |
| Shard | 102 (laksa) |
| Root Hash | 11087354373600355702 |
| Unparsed URL | com,educationecosystem!/blog/javascript-check-hidden-element/ s443 |