返回到:Prototype – 元素对象
此方法查找与给定选择器匹配的当前元素的所有兄弟,并将它们作为数组返回。
语法
element.adjacent([ selectors...]);
返回值
一组 HTML 元素。
例子
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function listCities() { var arr = $('nyc').adjacent('li.us'); arr.each(function(node) { alert(node.nodeName + ': ' + node.innerHTML); }); } </script> </head> <body> <ul id = "cities"> <li class = "us" id = "nyc">New York</li> <li class = "uk" id = "lon">London</li> <li class = "us" id = "chi">Chicago</li> <li class = "jp" id = "tok">Tokyo</li> <li class = "us" id = "la">Los Angeles</li> <li class = "us" id = "aus">Austin</li> </ul> <br /> <input type = "button" value = "List Cities" onclick = "listCities();"/> </body> </html>
返回到:Prototype – 元素对象
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9151.html