Prototype - visible() Method



This method returns a Boolean indicating whether or not the element is visible i.e., 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.

Syntax

element.visible();

Return Value

An HTML element.

Example

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      
      <script>
         function showResult() {
            if( $('visible').visible() ) {
               alert("$('visible').visible() returns true" );
            } else {
               alert("$('visible').visible() returns false" );
            }

            if( $('hidden').visible() ) {
               alert("$('hidden').visible() returns true" );
            } else {
               alert("$('hidden').visible() returns false" );
            }
         }
      </script>
   </head>

   <body>
      <p>Click button to see the result</p>
      
      <div id = "visible" style = "display:block;">
         This is visible division
      </div>
      
      <div id = "hidden" style = "display: none;">
         This is hidden division
      </div>
      
      <input type = "button" value = "Click" onclick = "showResult();"/>
   </body>
</html>

Output

prototype_element_object.htm
Advertisements