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 :: Number.prototype.between = function(a, b) { var min = Math.min.apply(Math, [a, b]), max = Math.max.apply(Math, [a, b]); return this min && this < max; }; 
Javascript :: nodejs sqlite create db if not exists 
Javascript :: escape xss javascript 
Javascript :: install react hotjar 
Javascript :: get file extension of path extendscript 
Javascript :: javascript img visible 
Javascript :: pandas json_normalize column with json array 
Javascript :: set time slots with date in javascript 
Javascript :: a function that returns a string javascript 
Javascript :: jquery has class 
Javascript :: formgroup angular 
Javascript :: google places autocomplete react native 
Javascript :: event.target.name in setstate 
Javascript :: jquery daterangepicker using moment 
Javascript :: redis to promise 
Javascript :: lite youtube embed react 
Javascript :: .yarnrc.yml get node module back 
Javascript :: Create buffers from strings using the Buffer.from() function. Like toString(), you can pass an encoding argument to Buffer.from(). 
Javascript :: add to array applescript 
Javascript :: javascript eingabe in inputfielder übernehmen 
Javascript :: how to use mdbreact in react js 
Javascript :: javascript select2 sortable 
Javascript :: make shorter if statements with objects 
Javascript :: webpack.config.js 
Javascript :: useref array 
Javascript :: electron in webpack 
Javascript :: javascript get first element of array 
Javascript :: array last element 
Javascript :: eslint disable line 
Javascript :: postman environment variable 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =