element.target in javascript code example
Example 1: JAVASCRIPT EVENT.TARGET
event.target returns the node that was targeted by the function.
This means you can do anything you would do with any other node like one
you'd get from document.getElementById
Example 2: javascript .target
const ul = document.createElement('ul');
document.body.appendChild(ul);
const li1 = document.createElement('li');
const li2 = document.createElement('li');
ul.appendChild(li1);
ul.appendChild(li2);
function hide(evt) {
evt.target.style.visibility = 'hidden';
}
ul.addEventListener('click', hide, false);