“document.addeventListener” Código de respuesta

addEventListener hover js

let test = document.getElementById("test");

test.addEventListener("mouseover", function( event ) {
  alert("mouse over test!")
  , false);
Jeff Spicoli

JavaScript Onclick Event Listener

document.getElementById("myBtn").addEventListener("click", function() {
  alert("Hello World!");
});
Batman

JavaScript addEventListener

var element = document.getElementById("#id");
element.addEventListener('click', function(){
	console.log("click");
});
Innocent Ibis

oyente de eventos JavaScript

const element = document.querySelector(".class__name");

element.addEventListener("click", () => {
	console.log("clicked element");
});
Levaillant's Barbet

JS Document.addeventListner

//Syntax
target.addEventListener(type, listener);
//Example 
document.addEventListener("click", modifyText);
//HTML
<table id="outside">
  <tr><td id="t1">one</td></tr>
  <tr><td id="t2">two</td></tr>
</table>
//JavaScript
// Function to change the content of t2
function modifyText(new_text) {
  const t2 = document.getElementById("t2");
  t2.firstChild.nodeValue = new_text;
}
// Function to add event listener to table
const el = document.getElementById("outside");
el.addEventListener("click", function(){modifyText("four")}, false);
Encouraging NeoBliz

document.addeventListener

java script
icon ke

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código