返回到:Prototype – 元素对象
此方法检查元素是否与给定的 CSS 选择器匹配。
语法
element.next( [cssRule][, index = 0]);
返回值
如果找到一个元素,则返回 HTML 元素,否则返回undefined。
例子
HTML
x
45
45
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
var str = $('list-of-apples').next();
9
alert( "$('list-of-apples').next() " + str.innerHTML );
10
11
var str = $('list-of-apples').next(0);
12
alert( "$('list-of-apples').next(0) " + str.innerHTML );
13
14
var str = $('title').next('p');
15
alert( "$('$('title').next('p') " + str.innerHTML );
16
17
var str = $('golden-delicious').next('.yummy', 1);
18
alert( "$('golden-delicious').next('.yummy', 1) " + str.innerHTML);
19
20
var str = $('ida-red').next();
21
alert( "$('ida-red').next() " + str );
22
}
23
</script>
24
</head>
25
26
<body>
27
<p>Click the button to see the result.</p>
28
29
<ul id = "fruits">
30
<li id = "apples">
31
<h3 id = "title">Apples</h3>
32
<ul id = "list-of-apples">
33
<li id = "golden-delicious">Golden Delicious</li>
34
<li id = "mutsu">Mutsu</li>
35
<li id = "mcintosh" class = "yummy">McIntosh</li>
36
<li id = "ida-red" class = "yummy">Ida Red</li>
37
</ul>
38
<p id = "saying">An apple a day keeps the doctor away.</p>
39
</li>
40
</ul>
41
<br />
42
43
<input type = "button" value = "Show Result" onclick = "showResult();"/>
44
</body>
45
</html>
返回到:Prototype – 元素对象
阅读剩余 86%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9068.html