返回到:Prototype – 元素对象
此方法返回元素的 id 属性(如果存在),或者设置并返回一个唯一的、自动生成的 id。
语法
element.identify();
返回值
返回 HTML 元素 ID。
例子
HTML
x
27
27
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 = $('apple').identify();
9
alert("Apple's ID: " + str );
10
var str = $('apple').next().identify()
11
alert("Orange's ID: " + str );
12
}
13
</script>
14
</head>
15
16
<body>
17
<p>Click the button to see the result.</p>
18
19
<ul>
20
<li id = "apple">apple</li>
21
<li>orange</li>
22
</ul>
23
<br />
24
25
<input type = "button" value = "Click" onclick = "showResult();"/>
26
</body>
27
</html>
返回到:Prototype – 元素对象
阅读剩余 79%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9086.html