返回到:Prototype – 元素对象
此方法收集元素的所有下一个兄弟元素并将它们作为扩展元素数组返回。
注– 如果两个元素具有相同的父元素,则它们是兄弟元素。
语法
element.nextSiblings();
返回值
一组 HTML 元素。
例子
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var str = $('mutsu').nextSiblings();
alert( "$('mutsu').nextSiblings() " + str[0].innerHTML );
alert( "$('mutsu').nextSiblings() " + str[1].innerHTML );
var str = $('ida-red').nextSiblings();
alert( "$('ida-red').nextSiblings() " + str[0] );
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<ul>
<li id = "golden-delicious">Golden Delicious</li>
<li id = "mutsu">Mutsu</li>
<li id = "mcintosh">McIntosh</li>
<li id = "ida-red">Ida Red</li>
</ul>
<br />
<input type = "button" value = "Click" onclick = "showResult();"/>
</body>
</html>返回到:Prototype – 元素对象
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9065.html
支付宝
微信