Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js get custom attribute

document.getElementById("divId").getAttribute("attributeId");
Comment

javascript get element by custom attribute

document.querySelector("div[data-automation='something']")

Select element by custom attribute
Comment

javascript get custom attribute value from element

<!-- TRYING TO ACCESS TO CUSTOM ATTRIBUTES WITH JAVASCRIPT ? -->

<article
  id="electric-cars"
  data-columns="3"
  data-index-number="12314"
  data-parent="cars">
</article>

<script>
// const article = document.getElementById("electric-cars")
article.dataset.columns // "3"
article.dataset.indexNumber // "12314"
article.dataset.parent // "cars"
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: first child element javascript 
Javascript :: js math round up 
Javascript :: message.channel.fetchMessages is not a function 
Javascript :: show password on click button jquery 
Javascript :: select2 on change 
Javascript :: how to remove the last character of a string in javascript 
Javascript :: _redirects in netlify 
Javascript :: iseven js 
Javascript :: delete all children of div 
Javascript :: ReactDOM.render is no longer supported in React 18. Use createRoot instead 
Javascript :: how to get current screen name in react native 
Javascript :: angular rebuild 
Javascript :: mongoose model find all documents with ids in array 
Javascript :: get data and time in javascript 
Javascript :: js extract domain from email 
Javascript :: jquery get element id 
Javascript :: chart js title 
Javascript :: javascript remove space from two side of string 
Javascript :: jquery onchange input value 
Javascript :: find intersection of multiple arrays in javascript 
Javascript :: fatal no configured push destination 
Javascript :: puppeteer how to serch for text 
Javascript :: button click redirection to another page vue 
Javascript :: title case javascript 
Javascript :: firstElementChild jquery equivalent 
Javascript :: check one checkbox at a time jquery 
Javascript :: await settimeout 
Javascript :: Math.random javascript double 
Javascript :: javascript Convert an array of strings to numbers 
Javascript :: resolveJsonModule 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =