Create a Link Element
mediumQuestion 181Create a new <a> element with href "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 with document.createElement("a").
2. Set its href with setAttribute("href", "https://example.com") and its textContent to "Visit".
3. Append it with nav.appendChild().
Expected output
<nav id="nav"> <a href="https://example.com">Visit</a> </nav>
= newline. No newline after the last line.
Hints4 available
Sign in to use hintsTopics
HTML DOM
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.