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
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
even.target in javascript
// Make a list
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) {
// e.target refers to the clicked <li> element
// This is different than e.currentTarget, which would refer to the parent <ul> in this context
evt.target.style.visibility = 'hidden';
}
// Attach the listener to the list
// It will fire when each <li> is clicked
ul.addEventListener('click', hide, false);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us