js getattribute
document.getElementById('id1').getAttribute('attribute');const link = document.querySelector('a');
console.log(link.getAttribute('href'));<div id="id_of_the_element" data-attribute_name="foo"></div>
var elem = document.getElementById("id_of_the_element");
var attribute_value = elem.getAttribute("data-attribute_name");
//OR with jquery...
var attribute_value = $('#id_of_the_element').attr('data-attribute_name');
//OR...
var attribute_value = $('#id_of_the_element').data('attribute_name');
document.querySelectorAll('[data-foo="value"]');
Also in JavaScript:
- servicenow json insert
- array contains case insensitive javascript
- ladder physics javascript
- javascript rgb to hex
- read xlsx file in angular 5
- javascript array to comma separated list
- jquery check if checkbox is not checked
- angular material remove outline
- exponent of two numbers in javascript
- js filter items by index
- react check if string is mail
- are you sure you want to proceed click ok button javascript code
- js clear text in input
- vuejs remove object from array
- google analytics nextjs
- set checkbox checked jquery
- open html file in browser using package.json
- how to edit the visibiility of an element javscript
- jquery on input
- js call function by string name
- javascript object get property or default
- await inside map js
- javascript gcd
- odoo submit form using js and display data