0

在此我想要一个功能,当用户单击“按钮 01 ”时,它应该使 DIVid“ 01 ”可见。在此之后,当单击其他按钮时,它应该隐藏以前的 DIVid并使相关的DIVid可见。

我创造了一个小提琴

function Visibility() {
    var har_element = document.getElementById('C');
    var meth_element = document.getElementById('D');
    var main_element = document.getElementById('E');

    var vis = har_element.style;    

    if(vis.display == 'block') {vis.display = 'block';
        meth_element.style.display='block';
        main_element.style.display='block';
    } else {
        vis.display = 'block';
        meth_element.style.display='block';
        main_element.style.display='block';
    }
}
4

1 回答 1

1

尝试这个

window.onload = function(){
hideSomeDivs();

}

function showHide(showHidebuttonId)
{
   hideAll();

if(showHidebuttonId == "1")
  document.getElementById("first").style.display = 'block';
else if(showHidebuttonId == "2")
  document.getElementById("second").style.display = 'block';
else if(showHidebuttonId == "3")
 document.getElementById("third").style.display = 'block';
else if(showHidebuttonId == "4")
  document.getElementById("fourth").style.display = 'block';
 else if(showHidebuttonId == "5")
  document.getElementById("fifth").style.display = 'block';
}

  function hideAll(){
    document.getElementById("first").style.display = 'none';
    document.getElementById("second").style.display = 'none';
    document.getElementById("third").style.display = 'none';
    document.getElementById("fourth").style.display = 'none';
    document.getElementById("fifth").style.display = 'none';
  }
  function hideSomeDivs()
  {
   document.getElementById("second").style.display = 'none';
    document.getElementById("third").style.display = 'none';
  }
于 2013-04-19T04:40:55.227 回答