Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get element by click

document.addEventListener('click', function(e) {
    e = e || window.event;
    var target = e.target || e.srcElement,
        text = target.textContent || target.innerText;   
}, false);
Comment

get element by click

window.onclick = e => {
    console.log(e.target.innerText);
} 
Comment

get element by click

window.onclick = e => {
    console.log(e.target);  // to get the element
    console.log(e.target.tagName);  // to get the element tag name alone
} 
Comment

PREVIOUS NEXT
Code Example
Javascript :: js iterate match indexes 
Javascript :: add active class to li onclick react 
Javascript :: addclass javascript 
Javascript :: window.location.href 
Javascript :: object key map javascript 
Javascript :: object to array javascript 
Javascript :: compare 2 array element 
Javascript :: js random numbers 
Javascript :: js test undefined 
Javascript :: ajax file upload from modal 
Javascript :: next js back to previous page 
Javascript :: laravel data return in json 
Javascript :: install swagger jsdoc 
Javascript :: return response json two variables laravel 
Javascript :: consoleLine 
Javascript :: vue cli - Uncaught SyntaxError: Unexpected token < 
Javascript :: loop array reverse 
Javascript :: check if url is http or https javascript 
Javascript :: javascript WeakSet Methods 
Javascript :: route pass props to component 
Javascript :: createelement with id javascript 
Javascript :: set image size phaser 
Javascript :: javascript array find element by id 
Javascript :: remove special characters from string 
Javascript :: how to avoid json decode problem in python 
Javascript :: ngswitchcase in angular 8 
Javascript :: axios network error react native 
Javascript :: javascript compare arrays 
Javascript :: laravel using react 
Javascript :: How to lock Orientation for a particular screen in ios in react native 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =