Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Prototype observe () Method


previous next AddThis Social Bookmark Button


Advertisements

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>

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements