+ -
当前位置:首页 → 问答吧 → 一个简单的问题,搞不懂哪里出错

一个简单的问题,搞不懂哪里出错

时间:2011-12-28

来源:互联网

就是一个简单的鼠标点击按钮显示、隐藏div的功能
但是在ie中不好用,点第一次显示,必须鼠标先点网页的其余部分,再单击按钮才能隐藏?
在火狐中运行正常。
请问是焦点问题还是缓存问题。网页有好几个类似鼠标单击按钮,其余都好用,就这个不好用

JS部分
function import_file()
{
o2=document.getElementById('edit_tr');
o2.style.display=(o2.style.display!='none' ? 'none' : 'block');
}

HTML部分
<tr id="edit_tr" style="display:none">
<td height="48" bgcolor="#FAFAF1" colspan="19">

  <!--省去-->
</td>
</tr>

作者: mafeifan   发布时间: 2011-12-28

HTML code

<!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></title>
    <script>        function import_file() {
            o2 = document.getElementById('edit_tr');
            o2.style.display = (o2.style.display != 'none' ? 'none' : 'block');
        }</script>
</head>
<body>
    <table>
        <tr id="edit_tr" style="display:none;">
            <td height="48" bgcolor="#FAFAF1" colspan="19">
            </td>
        </tr>
    </table>
    <input type="button" onclick="import_file()" />
</body>
</html>

把你代码拿过来测试没有问题啊

作者: zsx841021   发布时间: 2011-12-28

单击按钮,是不是‘单选按钮’?
如果是的话,将onchange改成onclick事件。

作者: EEXXTTJJSS   发布时间: 2011-12-28

测试了 没有问题 发全部代码看看

作者: luliangshu350   发布时间: 2011-12-28