- Prototype - Home
- Prototype - Short Overview
- Prototype - Useful Features
- Prototype - Utility Methods
- Prototype - Element Object
- Prototype - Number Processing
- Prototype - Strings Processing
- Prototype - Array Processing
- Prototype - Hash processing
- Prototype - Basic Object
- Prototype - Templating
- Prototype - Enumerating
- Prototype - Event Handling
- Prototype - Form Management
- Prototype - JSON Support
- Prototype - AJAX Support
- Prototype - Expressing Ranges
- Prototype - Periodical Execution
Prototype - inspect() Method
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>
Output
prototype_element_object.htm
Advertisements