:visible Selector

visible selector

version added: 1.0jQuery(':visible')

Description: Selects all elements that are visible.

Elements can be considered hidden for several reasons:

  • They have a display value of none.
  • They are form elements with type="hidden".
  • Their width and height are explicitly set to 0.
  • An ancestor element is hidden, so the element is not shown on the page.

How :visible is calculated was changed in jQuery 1.3.2. The release notes outline the changes in more detail.


Make all visible divs turn yellow on click.

<!DOCTYPE html>
  div { width:50px; height:40px; margin:5px; border:3px outset green; float:left; }
  .starthidden { display:none; }
  <script src="http://code.jquery.com/jquery-latest.js"></script>
	<button>Show hidden to see they don't change</button>
  <div class="starthidden"></div>

  <div style="display:none;"></div>
    $("div:visible").click(function () {
      $(this).css("background", "yellow");
    $("button").click(function () {