I am struggling with updating my navigation bar so that the first item becomes a clickable link instead of just a list item. I attempted to add a link to the existing list item, but I think I should be using the .setAttribute
method in order to achieve this. Can someone assist me in creating a functioning link for the first item in my navigation bar?
<nav>
<ul>
<li class="navigation">HTML</li>
<li class="navigation">DOM</li>
<li class="navigation">Javascript</li>
</ul>
</nav>
function newLink () {
var navigation = document.getElementsByClassName("navigation");
var existingText = navigation[0].innerHTML;
var a = document.createElement("a");
a.setAttribute("href", existingText);
a.innerHTML = existingText;
document.getElementsByClassName("navigation")[0].appendChild(a);
}
newLink();