- Prototype 教程
- Prototype- 首页
- Prototype- 简短概述
- Prototype- 有用功能
- Prototype- 实用方法
- Prototype- 元素对象
- Prototype- 数字处理
- Prototype- 字符串处理
- Prototype- 数组处理
- Prototype- 散列处理
- Prototype- 基本对象
- Prototype- 模板化
- Prototype- 枚举
- Prototype- 事件处理
- Prototype- 表单管理
- Prototype- JSON 支持
- Prototype- AJAX 支持
- Prototype- 表达范围
- Prototype- 定期执行
- Prototype 有用资源
- Prototype- 快速指南
- Prototype- 有用资源
- Prototype- 讨论
原型- inspect() 方法
此方法返回元素的面向调试的字符串表示形式。Prototype 为内置和库定义的多种类型(如 String、Array、Enumerable 和 Hash)提供 inspect 方法,这些方法试图为各自的类型提供最有用的字符串表示形式。
undefined 和 null 表示为这些值。
其他类型查找 inspect 方法:如果有,则使用此方法;否则,会恢复到 toString 方法。
语法
element.inspect();
返回值
返回插入内容后 HTML 元素。
示例
<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>
输出
prototype_element_object.htm
广告