返回到:Prototype – 元素对象
此方法返回作为元素的第一个子元素。这与firstChild DOM 属性相反,它将返回任何节点。
语法
element.firstDescendant();
返回值
它返回一个 HTML 元素。
例子
HTML
x
28
28
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
desc = $('grandfather').firstDescendant();
9
alert("First Descendant is : " + desc.nodeName + ':' + desc.innerHTML );
10
child = $('grandfather').firstChild;
11
alert("First Child is : " + child.toString() );
12
}
13
</script>
14
</head>
15
16
<body>
17
<p>Click the button to see the result.</p>
18
19
<div id = "grandfather">This is grand father
20
<div id = "father"> This is father.
21
<div id = "kid">This is kid</div>
22
</div>
23
</div>
24
<br />
25
26
<input type = "button" value = "showResult" onclick = "showResult();"/>
27
</body>
28
</html>
返回到:Prototype – 元素对象
阅读剩余 42%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9111.html