Tutorials Point

  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint

  Home     References     Discussion Forums     About TP  

Prototype inspect() Method

previous next AddThis Social Bookmark Button


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 attempt 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.



Return Value:

  • Returns HTML element after inserted content.


<title>Prototype examples</title>

<script type="text/javascript" 

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 );


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

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

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


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

previous next Printer Friendly