function checkTarget(e) {
var el, elMsg;
if (!e) {
e = window.event;
}
el = e.target || e.srcElement;
elMsg = el.tagName;
elMsg.innerHTML = "Target is: " + elMsg;
}
var elName = document.getElementById('feedback');
elName.addEventListener('click', function(e) {
checkTarget(e);
}, false);
Pullo I understand your point, but on w3schools on target example they don’t have any css and on what you click will show, display the name of that element. This is their example:
<body onclick="myFunction(event)">
<p>Click on any elements in this document to find out which element triggered the onclick event.</p>
<h1>This is a heading</h1>
<button>This is a button</button>
<p id="demo"></p>
<script>
function myFunction(event) {
var x = event.target;
document.getElementById("demo").innerHTML = "Triggered by a " + x.tagName + " element";
}
</script>
</body>
Please tell me how do you explain this, comparing with what you told me to my function?