我在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 undefined.为什么? 原文链接:https://www.f2er.com/css/242184.html