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 :: map method 
Javascript :: comentar en javascript 
Javascript :: sorting an array 
Javascript :: npm read email 
Javascript :: check if is array javascript 
Javascript :: input variable in string javascript 
Javascript :: array objects 
Javascript :: javascript no decimal places 
Javascript :: asp net core use newtonsoft json 
Javascript :: stringbuffer javascript 
Javascript :: JavaScript HTML DOM Event 
Javascript :: react variable in stirng 
Javascript :: postgres json 
Javascript :: how to get nested array using lodash 
Javascript :: download canvas to png 
Javascript :: java script removing first three indexes 
Javascript :: for loop in react native 
Javascript :: hrtime to milliseconds 
Javascript :: javascript canvas load image 
Javascript :: parse json java 
Javascript :: array js 
Javascript :: julia function 
Javascript :: double bang js 
Javascript :: add array type to sequelize migration 
Javascript :: row append and calculation in jquery datatable 
Javascript :: check if string javascript 
Javascript :: how to create module in react 
Javascript :: component navigation without changin the url react router 
Javascript :: combine all ts files into one js 
Javascript :: tablica w javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =