任何人都可以告诉我为什么即使通过使用fireBug调试脚本正确地找到了正确的元素,style.display也不会更新ul的属性,而该属性仍然设置为none?
<html>
<div id="nav">
<ul>
<li><a href="" onmouseover="show()">Studio</a>
</li>
</ul>
</div>
<div id="subnav1">
<ul style="display: none">
<li><a href="">normally hidden</a>
</li>
</ul>
</div>
<script type="text/javascript" src="jquery-1.4.3.min.js"></script>
<script type="text/javascript">
function show()
{
var subNav1 = document.getElementById("subnav1");
var ull = subNav1.getElementsByTagName("ul");
for (var i = 0, ii = ull.length; i < ii; i++)
{
if(ull[i].style.display == "visible")
{
ull[i].style.display = "none";
}
else
{
ull[i].style.display = "visible";
}
}
};
</script>
</html>
答案 0 :(得分:8)
“visible”不是有效的css显示值。我想你正在寻找“阻止”