Add event listener to form : Event Handler « Event « JavaScript Tutorial
- JavaScript Tutorial
- Event
- Event Handler
<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>