返回到:Prototype – 元素对象
此方法返回元素的面向调试的字符串表示形式。Prototype 为许多类型提供检查方法,包括内置的和库定义的,例如 String、Array、Enumerable 和 Hash,它们试图为它们各自的类型提供最有用的字符串表示。
- undefined和null就是这样表示的。
- 查找其他类型以查找检查方法:如果有,则使用它,否则,它恢复为toString方法。
语法
element.inspect();
返回值
插入内容后返回 HTML 元素。
例子
HTML
x
33
33
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
var str = $('golden-delicious').inspect();
9
alert("$('golden-delicious').inspect(): " + str );
10
11
var str = $('mutsu').inspect();
12
alert("$('mutsu').inspect() : " + str );
13
14
var str = $('mutsu').next().inspect();
15
alert("$('mutsu').next().inspect() : " + str );
16
}
17
</script>
18
</head>
19
20
<body>
21
<p>Click the button to see the result.</p>
22
23
<ul>
24
<li id = "golden-delicious">Golden Delicious</li>
25
<li id = "mutsu" class = "yummy apple">Mutsu</li>
26
<li id = "mcintosh" class = "yummy">McIntosh</li>
27
<li</li>
28
</ul>
29
<br />
30
31
<input type = "button" value = "Click" onclick = "showResult();"/>
32
</body>
33
</html>
返回到:Prototype – 元素对象
阅读剩余 82%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9080.html