How to select all visible or hidden elements in a HTML page using jQuery ? Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In order to select all visible or hidden elements in a page using jQuery, we can use the following jQuery selectors: :visible Selector The visible Selector is used to select all the elements that are currently visible in the document. Syntax: $(":visible") :hidden Selector The hidden selector selects hidden elements to work upon. Syntax: $(":hidden") Below example illustrates the above approach: Example: html <!DOCTYPE html> <html> <head> <title> How to select all visible or hidden elements in a HTML page using jQuery ? </title> <script src= "https://code.jquery.com/jquery-1.12.4.min.js"> </script> <style> h1 { color: green; } h4 { color: green; } body { text-align: center; } .geeks { display: inline-block; font: bold 16px sans-serif; color: green; } .hidden { display: none; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h3> How to select all visible or hidden elements<br>in a HTML page using jQuery </h3> <div class="geeks">GeeksforGeeks</div> <div class="geeks hidden"> A Computer Sciecne Portal </div> <div class="geeks">For Geeks</div> <div class="geeks hidden"> Learn Contribute Explore </div> <br> <button type="button" class="visibleg"> Visible </button> <button type="button" class="hiddeng"> Hidden </button> <br> <h4></h4> <script> $(document).ready(function() { $(".visibleg").click(function() { var visibleBoxes = []; $.each($(".geeks"), function() { if ($(this).is(":visible")) { visibleBoxes.push($(this).text()); } }); $("h4").text("Visible items are - " + visibleBoxes.join(", ")); }); // Get hidden items $(".hiddeng").click(function() { var hiddenBoxes = []; $.each($(".geeks"), function() { if ($(this).is(":hidden")) { hiddenBoxes.push($(this).text()); } }); $("h4").text("Hidden items are - " + hiddenBoxes.join(", ")); }); }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to select multiple elements using jQuery ? S shubhamsingh10 Follow Improve Article Tags : JQuery jQuery-Misc Similar Reads How to Hide an HTML Element in Mobile View using jQuery ? Suppose we have given an HTML document and the task is to hide an HTML element in mobile view with the help of jQuery. Approach: Initially, we are required to detect whether our system is 'Mobile' or not, for that window.navigator.userAgent property is used. It returns a string containing informatio 2 min read How to select elements with no visible children using jQuery ? In this article we are going to learn how to select elements whose property is not visible or hidden. It simply means that the display property of that particular element is hidden, and we need to show whatever present in that element using the Jquery.We can easily do this by using the Jquery:hidden 2 min read How to Select All Elements without a Given Class using jQuery? In jQuery, selecting elements that do not have a specific class can be useful when you want to manipulate or style all elements except those matching a certain condition. This approach allows for more precise control over the elements in various dynamic situations.Here we have some common approaches 2 min read How to find all paragraph elements using jQuery ? Given a webpage containing paragraph elements and the task is to find every paragraph element using the jQuery module. We have to find the <p> elements from the HTML page, and you can achieve this task by using the element selectors. The element selector will select the element based on the el 2 min read How to select multiple elements using jQuery ? In this article, we will learn how to select multiple elements using JQuery. JQuery is the fastest and most lightweight JavaScript library that is used to simplify the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript. JQuery is widely famou 2 min read How to select direct parent element of an element in jQuery ? In this article, we will select the direct parent element of an element using jQuery. To select the direct parent element, the parent() method is used. This method finds the parent element related to the selected element. This parent() method traverses a single level up the selected element and retu 1 min read Like