Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js event target

const button = document.querySelector(".button");

button.addEventListener("click", function (evt) {
    // the event Target variable will contain the button element that we clicked on
    const eventTarget = evt.target;
    eventTarget.setAttribute("disabled", true);
}); 
Comment

javascript .target

// 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);
Comment

event.target javascript

const theTarget = someEvent.target;
Comment

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
Comment

event.target

// 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) {
  // evt.target refers to the clicked <li> element
  // This is different than evt.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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: json comment 
Javascript :: command to check dependencies in angular 
Javascript :: superagent set cookie 
Javascript :: chrome block javascript alert 
Javascript :: how to get the value of textarea in react 
Javascript :: JavaScript querySelector - By Attribute 
Javascript :: how to create password generator in react 
Javascript :: arr.sort 
Javascript :: mysql json 
Javascript :: how can hide link from inspect element 
Javascript :: vue compare two dates 
Javascript :: how to connect react to backend 
Javascript :: javascript unique array 
Javascript :: Put Variable Inside JavaScript String 
Javascript :: json to pdf javascript 
Javascript :: angular material datepicker range get value 
Javascript :: vue implode array 
Javascript :: array with object same keys 
Javascript :: pass data between pages react 
Javascript :: react native google places autocomplete 
Javascript :: flutter response to json 
Javascript :: how to make a progress bar in react 
Javascript :: js html object 
Javascript :: cek versi node js 
Javascript :: hashing passwords with bcrypt 
Javascript :: findone and update mongoose 
Javascript :: async function in variable 
Javascript :: How to use AlpineJS with Laravel Mix 
Javascript :: how to pick date from datepicker in selenium 
Javascript :: javascript boolean 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =