target javasc code example
Example 1: 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);
Example 2: what is e.target in javascript
The target property gets the element on which the event originally occurred,
opposed to the currentTarget property, which always refers to the element
whose event listener triggered the event.