I am facing an issue with replacing the contents of a NAV tag that contains UL list items. The original HTML within the NAV tag works perfectly fine, but when I replace it with my own HTML - which matches the original word for word - the dropdown functionality of the NAV stops working. I have meticulously compared every letter and word between the two versions. One thing I did notice is that one of the anchor HREF attributes contains a '#'. Here is the original code inside the NAV:
<nav id="nav">
<ul>
<li class="current"><a href="index.html">Welcome</a></li>
<li class="submenu">
<a href="#">Show Me</a>
<ul>
<li><a href="hybrid/index.html">The Hybrid</a></li>
</ul>
</li>
</ul>
</nav>
My code looks like this:
var pstrHTML = "<ul>"
+ "<li class='current'><a href='index.html'>Welcome</a></li>"
+ "<li class='submenu'>"
+ "<a href='#'>Show Me</a>"
+ "<ul>"
+ "<li><a href='hybrid/index.html'>The Hybrid</a></li>"
+ "</ul>"
+ "</li>"
+ "</ul>";
document.getElementById("nav").innerHTML = pstrHTML;
Although I have added an ONCLICK event with a WINDOW.ALERT to the "Show Me" list item, confirming that the INNERHTML replacement is functioning correctly on page load, the NAV is still not behaving as expected in comparison to the original HTML.