Add event listener to elements in a form : Form « Form Control « JavaScript DHTML






Add event listener to elements in a form

  

<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>

   
    
  








Related examples in the same category

1.Form length
2.On focus event
3.On focus lost event
4.Get input value from form control
5.Add event listener to form