“Javascript Event CurrentTarget” Respostas de código

Javascript Event CurrentTarget

function hide(e){
  e.currentTarget.style.visibility = 'hidden';
  console.log(e.currentTarget);
  // When this function is used as an event handler: this === e.currentTarget
}

var ps = document.getElementsByTagName('p');

for(var i = 0; i < ps.length; i++){
  // console: print the clicked <p> element
  ps[i].addEventListener('click', hide, false);
}
// console: print <body>
document.body.addEventListener('click', hide, false);

// Click around and make paragraphs disappear
Himanshu Jangid

CurrentTarget JavaScript

//Javascript
document.getElementById("foo").onclick = (e) => {
	e.target.style.backgroundColor = "#333";
	console.log(e.target.value)
    
    // Expected Output: "Hello World!"
}

//HTML
<input id="foo" type="text" value="Hello World!">
Q_Q

Respostas semelhantes a “Javascript Event CurrentTarget”

Perguntas semelhantes a “Javascript Event CurrentTarget”

Mais respostas relacionadas para “Javascript Event CurrentTarget” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código