此方法用于哈希键属性的值。
语法
hash.get(key);
返回值
返回对应于 paased 键的值。
例子
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 h = new Hash({ a: 'apple', b: 'banana', c: 'coconut' });
9
alert("Value of a : " + h.get('a') );
10
// -> 'apple'
11
12
alert("Value of b : " + h.get('b') );
13
// -> 'banana'
14
15
alert("Value of d : " + h.get('d') );
16
// -> undefined
17
}
18
</script>
19
</head>
20
21
<body>
22
<p>Click the button to see the result.</p>
23
<br />
24
<br />
25
<input type = "button" value = "Result" onclick = "showResult();"/>
26
</body>
27
</html>
阅读剩余 79%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8737.html