【发布时间】:2013-01-15 09:55:26
【问题描述】:
我在 stackoverflow 中找到了这个脚本。
function showhide(id){
if (document.getElementById) {
var divid = document.getElementById(id);
var divs = document.getElementsByClassName("hideable");
for(var div in divs) {
div.style.display = "none";
}
divid.style.display = "block";
}
return false;
}
<a href="#" onclick="showhide('features');" >features</a>
<a href="#" onclick="showhide('design');" >design</a>
<a href="#" onclick="showhide('create');" >create</a>
<div class="hideable" id="features">Div 1</div>
<div class="hideable" id="design">Div 2</div>
<div class="hideable" id="create">Div 3</div>
但它说 div.style 未定义。为什么? :)
【问题讨论】:
-
你用的是哪个浏览器??
-
IE版本小于9不支持该属性
标签: javascript html styles