Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
Comment

document.addeventlistener

java script
Comment

PREVIOUS NEXT
Code Example
Javascript :: reverse string js 
Javascript :: alert and prompt in javascript 
Javascript :: change the mouse pointer javascript 
Javascript :: remove duplicate object from array javascript 
Javascript :: javascript base 10 to base 2 
Javascript :: string includes substring javascript 
Javascript :: js form check all required input 
Javascript :: regular expression special characters 
Javascript :: datatable on page change 
Javascript :: word to char array javascript 
Javascript :: javascript tolocaletimestring 
Javascript :: Replace With Alphabet Position 
Javascript :: for loop value index react 
Javascript :: two sum javascript 
Javascript :: js find array return true false 
Javascript :: npm stylelint 
Javascript :: get object value in node js 
Javascript :: es6 create array with increasing number 
Javascript :: javascript element distance from top 
Javascript :: react useref 
Javascript :: get last item in array javascript 
Javascript :: random numbers javascript 
Javascript :: how to disable copy paste in input js 
Javascript :: check if element is visible or hidden in dom 
Javascript :: count word and space in text javascript 
Javascript :: vue js copy text to clipboard 
Javascript :: restrict the user from going to signup or login page if the user is already logged in firebase auth 
Javascript :: chartjs Uncaught ReferenceError: Utils is not defined 
Javascript :: .children javascript 
Javascript :: readystate in ajax 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =