1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 <p data-foo="0"></p>
6 <h6 data-foo="1"></h6>
7 <script>
8 var a = document.querySelectorAll('[data-foo]');
9
10 for (var i in a) if (a.hasOwnProperty(i)) {
11 alert(a[i].getAttribute('data-foo'));
12 }
13 </script>
14 </body>
15 </html>
16