Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset=utf-8 />
- <title>test data-*</title>
- <script src="data.js"></script>
- </head>
- <body>
- <p data-id="ok" data-name="remy" data-screen-name="rem" id="hello">Hello World</p>
- <script>
- var el = document.getElementById('hello'), dl = el.dataset, a = [], key;
- for (key in dl) a.push(key + ': ' + dl[key]);
- alert(a.join('\n'));
- a.length = 0;
- el.setAttribute('data-foo', 'bar');
- if (el._datasetCache) alert('Houston: we have a problem!');
- dl = el.dataset;
- for (key in dl) a.push(key + ': ' + dl[key]);
- alert(a.join('\n'));
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment