Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Prototype visible() Method


previous next AddThis Social Bookmark Button


Advertisements

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.

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>

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



previous next Printer Friendly

Advertisements


  

Advertisements