Prototype inspect() Method


Advertisements


This method returns the debug-oriented string representation of element. Prototype provides inspect methods for many types, both built-in and library-defined, such as in String, Array, Enumerable and Hash, which attempts to provide most-useful string representations for their respective types.

  • undefined and null are represented as such.
  • Other types are looked up for a inspect method: if there is one, it is used, otherwise, it reverts to the toString method.

Syntax

element.inspect();

Return Value

  • Returns HTML element after inserted content.

Example

<html>
<head>
<title>Prototype examples</title>

<script type="text/javascript" 
   src="/javascript/prototype.js">
</script>
<script>

function showResult(){
   var str = $('golden-delicious').inspect();
   alert("$('golden-delicious').inspect(): " + str );

   var str = $('mutsu').inspect();
   alert("$('mutsu').inspect() : " + str );

   var str = $('mutsu').next().inspect();
   alert("$('mutsu').next().inspect() : " + str );
}
</script>
</head>

<body>

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

  <ul>
     <li id="golden-delicious">Golden Delicious</li>
     <li id="mutsu" class="yummy apple">Mutsu</li>
     <li id="mcintosh" class="yummy">McIntosh</li>
     <li</li>
  </ul>

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

</body>
</html>

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


prototype_element_object.htm

Advertisements