Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react get data attribute from element

<div data-id={someId} >Test</div>

const id = e.target.getAttribute("data-id");
//alternate to getAttribute
const id = e.target.attributes.getNamedItem("data-id").value;
Comment

PREVIOUS NEXT
Code Example
Javascript :: React Navigation back() and goBack() not working 
Javascript :: fill checkbox javascript 
Javascript :: last element of array javascript 
Javascript :: commas for thousands js 
Javascript :: remove sliding animation from owl carousel 
Javascript :: visual code put quotes to each line 
Javascript :: how to make chart js from zero 
Javascript :: javascript tofixed only if decimal 
Javascript :: js nested backticks 
Javascript :: check if base64 
Javascript :: javascript object includes 
Javascript :: javascript clone array without reference 
Javascript :: JavaScript does not protect the property name hasOwnProperty 
Javascript :: event on input or keydown or on paste value or on change jquery 
Javascript :: js replace all number 
Javascript :: current datetime js 
Javascript :: how to terminate a program in js 
Javascript :: angular 10 set error on form controle 
Javascript :: vue js get width of element 
Javascript :: JS get number of classes in html 
Javascript :: loopback hasone 
Javascript :: node mailer office 365 
Javascript :: how to change specific object in array javascript 
Javascript :: JavaScript changing the color of an html element 
Javascript :: js clear local storage 
Javascript :: dynamics js search another entity 
Javascript :: node list folders in directory 
Javascript :: set value using javascript 
Javascript :: jQuery delete all spans in a div 
Javascript :: p5.js style 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =