Copyright ©

Prototype visible() Method

previous next


This method returns a Boolean indicating whether or not element is visible ie. whether its inline style property is set to "display: none;".

NOTE: Styles applied via a CSS stylesheet are not taken into consideration. Note that this is not a Prototype limitation, it is a CSS limitation.



Return Value:


<title>Prototype examples</title>

<script type="text/javascript" 

function showResult()
   if( $('visible').visible() ){
      alert("$('visible').visible() returns true" );
      alert("$('visible').visible() returns false" );

   if( $('hidden').visible() ){
      alert("$('hidden').visible() returns true" );
      alert("$('hidden').visible() returns false" );



  <p>Click button to see the result</p>

  <div id="visible" style="display:block;">
     This is visible division

  <div id="hidden" style="display: none;">
     This is hidden division

  <input type="button" value="Click" onclick="showResult();"/>


To understand it in better way you can Try it yourself.

previous next

Copyright ©