var src;
var subid;
var nob;
src = window.event.srcElement;

if (src.className == "menu")
{
subid = "sub" + src.id;

if (document.all(subid).style.display == "none")
{
document.all(subid).style.display == "block" }
else
{

document.all(subid).style.display == "none"
}
}
怎么我运行到第2个IF那没反映?请高手帮忙

解决方案 »

  1.   

    if (document.all(subid).style.display == "none")
    {
    document.all(subid).style.display == "block"
    }
    else
    {

    document.all(subid).style.display == "none"//这个是比较,不是付值
    }
    ===>>if (document.all(subid).style.display == "none")
    {
    document.all(subid).style.display ="block"
    }
    else
    {

    document.all(subid).style.display = "none"
    }
      

  2.   

    document.getElementById("subid").style.displayordocument.getElementsByName("subName")[0].style.display
      

  3.   

    document.all(subid).style.display == "none"
    ...你这个是说a等于b 
    并不是把b的值给a 
    记得用=
      

  4.   

    document.all(subid).style.display == "none"返回的是bool類型,而document.all(subid).style.display = "none"是賦值。
      

  5.   

    document.getElementById("subid").style.display
      

  6.   

    var src;
    var subid;
    var nob;
    src = window.event.srcElement;if (src.className == "menu")
    {
    subid = "sub" + src.id;if (document.all(subid).style.display == "none")
    {
    document.all(subid).style.display = "block"}
    else
    {document.all(subid).style.display = "none"
    }
    }