Skip to content
Browse files

Create Check-if-an-element-is-hidden-using-jQuery.md

This page is for **FrontEnd Related** second bullet point. Checkin if the element is hidden #367
  • Loading branch information...
1 parent 5a975fd commit 6c9cbd09813e4980546571d90f610395930d20fb @mkdizajn mkdizajn committed
Showing with 17 additions and 0 deletions.
  1. +17 −0 Check-if-an-element-is-hidden-using-jQuery.md
View
17 Check-if-an-element-is-hidden-using-jQuery.md
@@ -0,0 +1,17 @@
+# Checking if the element is currently hidden
+
+If you need to check the visibility status of some element on the page, you can do that easily with jQuery library with the simple block of code like the one below.
+
+```javascript
+var display = ( jQuery('#someElement').is(':visible') );
+var visibility = ( jQuery('#someElement').css('visibility') != 'hidden' );
+var status = ( display && visibility );
+console.log( status );
+```
+
+So, if the element is currently visible on the page the **`console.log(status)`** would return `true` and in any other case it would return `false`.
+The `false` statement would be returned for this two cases:
+- if element has `display:none;`
+- if element has `visibility: hidden`
+
+and for more advanced checking like this: **is the element visible on the viewport now** I would recomend to use [jQuery onScreen plugin](http://benpickles.github.io/onScreen/)

0 comments on commit 6c9cbd0

Please sign in to comment.
Something went wrong with that request. Please try again.