- 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
廣告