- 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 - 討論
Prototype - nextSiblings() 方法
此方法收集元素的所有後代兄弟元素,並將它們作為一個擴充套件元素陣列返回。
注意 - 如果兩個元素有相同的父元素,那麼它們就是兄弟元素。
語法
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_element_object.htm
廣告