返回到:Prototype – 元素对象
收集元素的所有子元素并将它们作为扩展元素数组返回。
索引 0 表示元素的最顶层子元素。
语法
element.childElements();
返回值
一组 HTML 元素。
例子
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showElements() {
var arr = $('father').childElements();
arr.each(function(node) {
alert(node.nodeName + ': ' + node.innerHTML);
});
}
</script>
</head>
<body>
<div id = "father">
<p id = "kid1">This is first paragraph</p>
<p id = "kid2">This is second paragraph</p>
</div>
<br />
<input type = "button" value = "showElements" onclick = "showElements();"/>
</body>
</html>返回到:Prototype – 元素对象
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9145.html
支付宝
微信