- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if a div is visible using jQuery?
You can use .is(‘:visible’) selects all elements that are visible.
Example
<html> <head> <title>divvisible</title> <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("button").click(function () { var dim = $('#div1').is(":visible"); if (dim == false) { $('#div1').css({ "display": "block", "color": "red" }); } }); }); </script> </head> <body> <div id="div1" style="display:none"> <p>Div is visible</p> </div> <button type="button" id="btn" onclick="click()">Click Here</button><br /> </body> </html>
- Related Articles
- How to duplicate a div using jQuery?
- How to toggle a div visibility using jQuery?
- How to check if an element is visible with WebDriver?
- FabricJS – How to check if a specified control is visible in Line?
- How to use protractor to check if an element is visible?
- How to create div dynamically using jQuery?
- How to print div content using jQuery?
- How to replace innerHTML of a div using jQuery?
- How to load a page in div using jQuery?
- How to copy the content of a div into another div using jQuery?
- How to replace only text inside a div using jQuery?
- How to center a div on the screen using jQuery?
- How to replace innerHTML of a div tag using jQuery?
- How to get innerHTML of a div tag using jQuery?
- How to check if element exists in the visible DOM?

Advertisements