Simple JavaScript function not working on IE7, no errors on DebugBar
-
18-10-2022 - |
Question
I have this HTML page with a simple function triggered onclick. This is on a link that makes a menu item show sub-items. This doesn't seem to work on IE7, however, it works on IE8+
JS:
function showSub(id)
{
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
HTML:
<div class="cssmenu">
<ul>
<li class="active"><a href="index.html"><span>Home</span></a></li>
<li><a href="about.html"><span>About</span></a></li>
<li class="has-sub"><a onclick="showSub('sub')"><span>Services</span></a>
<ul id="sub">
<li><a href="solutions.html"><span>Solutions</span></a>
</li>
<li><a href="company.html"><span>Company</span></a>
</li>
</ul>
</li>
<li class="last"><a href="contact.html"><span>Contact</span></a></li>
</ul>
</div>
CSS:
.cssmenu > ul > li > ul
{
font-family: 'Julius Sans One', sans-serif;
z-index: 999 !important;
display: none;
}
Thanks in advance
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow