1//HTML
2//<div id="elem" data-id="4hJ3s"></div>
3
4var elem = document.getElementById("elem");
5elem.getAttribute("data-id"); // "4hJ3s"
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