Guest User

Untitled

a guest
Jun 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset=utf-8 />
  5. <title>test data-*</title>
  6. <script src="data.js"></script>
  7. </head>
  8. <body>
  9. <p data-id="ok" data-name="remy" data-screen-name="rem" id="hello">Hello World</p>
  10. <script>
  11. var el = document.getElementById('hello'), dl = el.dataset, a = [], key;
  12. for (key in dl) a.push(key + ': ' + dl[key]);
  13. alert(a.join('\n'));
  14.  
  15. a.length = 0;
  16. el.setAttribute('data-foo', 'bar');
  17. if (el._datasetCache) alert('Houston: we have a problem!');
  18.  
  19. dl = el.dataset;
  20. for (key in dl) a.push(key + ': ' + dl[key]);
  21. alert(a.join('\n'));
  22. </script>
  23. </body>
  24. </html>
Add Comment
Please, Sign In to add comment