Source Code:
(back to article)
Submit
Result:
Report an issue
<div id="demo" data-author="Jane Doe" data-year="2022">Information Panel</div> <br /> <div>author: <span id="1"></span></div> <div>year: <span id="2"></span></div> <script> const element = document.getElementById("demo"); const span1 = document.getElementById("1"); const span2 = document.getElementById("2"); span1.innerHTML = element.dataset.author; span2.innerHTML = element.dataset.year; </script>