function showDiv(divID)
{
if(divID == 'div_current')
{
div_current.style.display == "block";
div_used.style.display == "none";
}
else
{
div_used.style.display == "block";
div_current.style.display == "none";
}
}

解决方案 »

  1.   

    var id = document.getElementById(divID);
    if(id == 'div_current')
    这句话有问题啊!
    你定义的id是一个object,而div_current看样子是个变量
      

  2.   

    id = document.getElementById(divID)得到的是一个对象,不能与字符串比较
      

  3.   

    To hookee:
    我试了,但还是不行,大家帮忙啊。
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Untitled Page</title>
    </head>
    <body>
        <table>
            <tr>
                <td style="width: 398px; height: 136px">div_used
                    <img src="images/2.jpg" onclick="showDiv('div_used')" height="50" width="50"></td>
                <td style="width: 398px; height: 136px">div_current
                    <img src="images/3.jpg" onclick="showDiv('div_current')" height="50" width="50"></td>
            </tr>
            <tr>
                <td style="width: 398px; height: 138px">
                    <div id="div_current" style="display: block;">div_current
                        <img src="images/banner.jpg" height="50" width="50">
                    </div>
                </td>
                <td style="width: 398px; height: 138px">
                        <div id="div_used" style="display: none;">div_used
                            <img src="images/4.jpg" height="50" width="50">
                        </div>
                </td>
            </tr>
            <tr>
                <td style="width: 398px; height: 116px">
                        </td>
                <td style="width: 398px; height: 116px">
                </td>
            </tr>
            <script language="javascript" type="text/javascript">
    function showDiv(divID)
    {
        var div_used = this.div_used;
        var div_current = this.div_current;
        if(divID== 'div_current')
        {
            div_current.style.display = "block";
            div_used.style.display = "none";
        }
        else
        {
            div_used.style.display = "block";
            div_current.style.display = "none";
        }
    }
            </script>
        </table>
    </body>
    </html>