📅  最后修改于: 2022-03-11 15:02:43.428000             🧑  作者: Mango
//Syntax
target.addEventListener(type, listener);
//Example
document.addEventListener("click", modifyText);
//HTML
one
two
//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);