The :visible selector selects every element that is currently visible.
Visible elements are elements that are not:
$(":visible")
Select all visible <p> elements:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p:visible").css("background-color", "yellow"); });/*from w ww .j a va2s . co m*/ </script> </head> <body> <h1>This is a heading</h1> <p>This is a pargraph.</p> <p>This is another paragraph.</p> <p style="display:none">This is a hidden paragraph.</p> </body> </html>