原型 - observe() 方法
此方法在元素上注册事件处理程序并返回元素。
语法
element.observe(eventName, handler[, useCapture = false]);
返回值
一个 HTML 元素。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function RegisterFunction() {
$('test').observe('click', function(event) {
alert(Event.element(event).innerHTML);
});
}
</script>
</head>
<body onload = "RegisterFunction();">
<p id = "test">Click me to see the result.</p>
</body>
</html>
输出
prototype_element_object.htm
广告