Get key event target element id : Target « Event « JavaScript Tutorial






<html>
<head>
<title>Key Events Example</title>
<script type="text/javascript">
function handleEvent(oEvent) {
    var oTextbox = document.getElementById("txt1");
    oTextbox.value += "\n>" + oEvent.type;
    oTextbox.value += "\n    target is " + (oEvent.target || oEvent.srcElement).id;
}
</script>
</head>
<body>
    <P>Type some characters into the first textbox.</p>
    <P><textarea id="txtInput" rows="15" cols="50"
        onkeypress="handleEvent(event)"></textarea></p>
    <P><textarea id="txt1" rows="15" cols="50"></textarea></p>
</body>
</html>








15.6.Target
15.6.1.Get key event target element id
15.6.2.Get mouse event target
15.6.3.Event Bubbling Demonstration
15.6.4.W3C Event Capture and Bubble