返回到:Prototype – 元素对象
此方法在元素上注册一个事件处理程序并返回元素。
语法
element.observe(eventName, handler[, useCapture = false]);
返回值
一个 HTML 元素。
例子
HTML
x
18
18
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function RegisterFunction() {
8
$('test').observe('click', function(event) {
9
alert(Event.element(event).innerHTML);
10
});
11
}
12
</script>
13
</head>
14
15
<body onload = "RegisterFunction();">
16
<p id = "test">Click me to see the result.</p>
17
</body>
18
</html>
返回到:Prototype – 元素对象
阅读剩余 71%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9062.html