CJCoding With Joseph

Create a Link Element

Create 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>
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.