- Prototype 教程
- Prototype - 主页
- Prototype - 简短概述
- Prototype - 有用的功能
- Prototype - 实用方法
- Prototype - 元素对象
- Prototype - 数字处理
- Prototype - 字符串处理
- Prototype - 数组处理
- Prototype - 散列处理
- Prototype - 基本对象
- Prototype - 模板创建
- Prototype - 枚举
- Prototype - 事件处理
- Prototype - 表单管理
- Prototype - JSON 支持
- Prototype - AJAX 支持
- Prototype - 表达范围
- Prototype - 周期性执行
- Prototype 有用资源
- Prototype - 快速指南
- Prototype - 有用资源
- Prototype - 讨论
原型 - get() 方法
该方法用于获得哈希键属性的值。
语法
hash.get(key);
返回值
返回一个与 passed 键对应的值。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var h = new Hash({ a: 'apple', b: 'banana', c: 'coconut' });
alert("Value of a : " + h.get('a') );
// -> 'apple'
alert("Value of b : " + h.get('b') );
// -> 'banana'
alert("Value of d : " + h.get('d') );
// -> undefined
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br />
<br />
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>
输出
prototype_hash_processing.htm
广告