Javascript examples for DOM:Element getAttribute
Get and set data attribute to element
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/* ww w . j a v a 2s. c o m*/ var ul = document.getElementById('id_name'); var data_id = ul.getAttribute('data-id'); console.log(data_id); }); </script> </head> <body> <ul class="trf noborder" data-id="6581" id="id_name"> </ul> </body> </html>