- Prototype - Home
- Prototype - Short Overview
- Prototype - Useful Features
- Prototype - Utility Methods
- Prototype - Element Object
- Prototype - Number Processing
- Prototype - Strings Processing
- Prototype - Array Processing
- Prototype - Hash processing
- Prototype - Basic Object
- Prototype - Templating
- Prototype - Enumerating
- Prototype - Event Handling
- Prototype - Form Management
- Prototype - JSON Support
- Prototype - AJAX Support
- Prototype - Expressing Ranges
- Prototype - Periodical Execution
Prototype - observe() Method
This method registers an event handler on element and returns element.
Syntax
element.observe(eventName, handler[, useCapture = false]);
Return Value
An HTML element.
Example
<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>
Output
prototype_element_object.htm
Advertisements