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 :: ytdl-core 
Javascript :: disable eslint 
Javascript :: javascript querySelectorAll id ends with 
Javascript :: how to detect which key is pressed in javascript 
Javascript :: check if string matches regex js 
Javascript :: javascript date get nearest 15 minutes 
Javascript :: js replace all 
Javascript :: react counter input 
Javascript :: how to change tab color react bootstraps customixation 
Javascript :: javascript convert in a string the items of an array 
Javascript :: javascript string remove backslash 
Javascript :: fibonacci javascript 
Javascript :: nodejs express hot reload 
Javascript :: js classlist 
Javascript :: javascript validate date 
Javascript :: how to check if function is running js 
Javascript :: list from 1 to 100 js 
Javascript :: vue on click router push not working 
Javascript :: getusermedia example 
Javascript :: set focus on load javascript 
Javascript :: javascript store text file into string 
Javascript :: ngmodel onchange 
Javascript :: React does not recognize the `activeClassName` prop on a DOM element 
Javascript :: get page link angular 
Javascript :: axios get error response message 
Javascript :: jquery format date 
Javascript :: node js performance is not defined 
Javascript :: how to submit form using ajax 
Javascript :: javascript join 
Javascript :: javascript append item to array 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =