Answers for "js add custom attribute"

3

js get custom attribute

document.getElementById("divId").getAttribute("attributeId");
Posted by: Guest on June-15-2021
13

javascript add attribute

var element = document.getElementById('btnBuild');
element.setAttribute("disabled", "disabled");
Posted by: Guest on June-23-2021
0

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>
Posted by: Guest on December-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language