Add event listener to form : Event Handler « Event « JavaScript Tutorial






<html>
<head>
<title></title>
<script type="text/javascript">
function writeX(evnt) {
   document.write("Capturing" + evnt.target + " " + evnt.currentTarget);
   return true;
}
function setup(evnt) {
   document.addEventListener('click',writeX,true);
   document.forms[0].addEventListener('click',writeX,true);
   document.forms[0].elements[0].addEventListener('click',writeX,true);

}

setup();
</script>
<body>
<form>
     <input type="submit" value="Submit" /><br>
</form>
</body>
</html>








15.12.Event Handler
15.12.1.Add event handler listener to document
15.12.2.Preventing Bubble and Capture
15.12.3.Register mouse down event(IE)
15.12.4.Event Handlers and this
15.12.5.Event Bubbling (Firefox)
15.12.6.Capturing events
15.12.7.Add event listener to form
15.12.8.Add event listener to elements in a form
15.12.9.Bubble up events (Firefox)
15.12.10.Inline DOM Event Registration