返回到:Prototype – 元素对象
此方法从文档中完全删除元素并返回它。
语法
element.remove();
返回值
返回删除的 HTML 元素。
例子
HTML
x
29
29
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 = $('mutsu').remove();
9
alert("Value of str : " + str.innerHTML );
10
11
var str = $('ida-red').remove();
12
alert("Value of str : " + str.innerHTML );
13
}
14
</script>
15
</head>
16
17
<body>
18
<p>Click the button to see the result.</p>
19
20
<ul>
21
<li id = "golden-delicious">Golden Delicious</li>
22
<li id = "mutsu">Mutsu</li>
23
<li id = "mcintosh">McIntosh</li>
24
<li id = "ida-red">Ida Red</li>
25
</ul>
26
27
<input type = "button" value = "Show Result" onclick = "showResult();"/>
28
</body>
29
</html>
返回到:Prototype – 元素对象
阅读剩余 43%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9023.html