1const link = document.querySelector('a');
2
3console.log(link.getAttribute('href'));
1<div id="id_of_the_element" data-attribute_name="foo"></div>
2
3var elem = document.getElementById("id_of_the_element");
4var attribute_value = elem.getAttribute("data-attribute_name");
5
6//OR with jquery...
7var attribute_value = $('#id_of_the_element').attr('data-attribute_name');
8//OR...
9var attribute_value = $('#id_of_the_element').data('attribute_name');
10
1<!-- example div in an html DOC -->
2<div id="div1">Hi Champ!</div>
3
4// in a console
5const div1 = document.getElementById('div1');
6//=> <div id="div1">Hi Champ!</div>
7
8const exampleAttr= div1.getAttribute('id');
9//=> "div1"
10
11const align = div1.getAttribute('align')
12//=> null
13
14