โ Back to HTML DOM
Question 142
Read a Data Attribute
Read a Data Attribute
Read thedata-usernamevalue from the div with id="widget" using itsdataset, and display it as the text of the span with id="output". The span should read "alice". Platform-Provided HTML (READ-ONLY): <div id="widget" data-username="alice"> <span id="output"></span> </div> Steps: 1. Access the value withwidget.dataset.username. 2. Assign it to thetextContentof#output.
Expected Output:
<div id="widget" data-username="alice"> <span id="output">alice</span> </div>
Topics:
HTML DOM
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.