โ Back to HTML DOM
Question 141
Create a Link Element
Create a Link Element
Create a new<a>element withhref"https://example.com" and text "Visit", then append it inside the nav with id="nav". Platform-Provided HTML (READ-ONLY): <nav id="nav"> </nav> Steps: 1. Create the anchor withdocument.createElement("a"). 2. Set its href withsetAttribute("href", "https://example.com")and itstextContentto "Visit". 3. Append it withnav.appendChild().
Expected Output:
<nav id="nav"> <a href="https://example.com">Visit</a> </nav>
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.