切换Internet Explorer中的可见性问题

时间:2011-08-26 13:54:35

标签: internet-explorer toggle visibility

我对编码比较陌生,但我已经建立了一个网站:RateMyTeam.co.uk(幻想足球分析),并且在与Internet Explorer的兼容性问题上遇到了一些问题。该网站在Chrome和Safari中运行良好,只有Firefox出现问题。但IE的问题是一个问题,超过30%的网站访问者使用IE浏览器。

在主页上,我使用javascript函数切换您可以看到的问题的可见性,例如“我的FPL ID是什么?”

在Chrome中,它会按照我的要求执行操作,即当您将鼠标悬停在其上时可以更改颜色,并且可以点击它并显示问题的答案。

有没有人有任何想法我的主页代码有什么问题阻止IE中的可见性切换?我已经通过众多论坛寻找答案并尝试了很多东西,但它似乎没有用! :■

谢谢,

克里斯

修改

这是代码:

html位:

<h5 style="text-shadow: #111 2px 2px 4px"><a2 href="#" onclick="toggleVisibility('foo6');">*WHAT IS MY FPL PLAYER ID?</a2></h5> 

 <div id="foo6" style="display:none;"><h6  style="margin-top:8px;margin-bottom:13px;color:#ccc">Each person who plays the fantasy football game at <a href="http://www.fantasy.premierleague.com">www.fantasy.premierleague.com</a> gets assigned a unique id. This is a number which can be as small as 1 digit and as big as 7 digits long.</h6></div> 

javascript位:

<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script type="text/JavaScript">
    function toggleVisibility(id) {
        var e = document.getElementById(id);
        if(e != null) { 
            if(e.style.display == 'none') {
                e.style.display = 'block';
            } else {
                e.style.display = 'none';
            }
        }
    }
</script> 

1 个答案:

答案 0 :(得分:0)

是的,您应使用有效的HTML(4/5)标记。如果对于相同类型的元素需要不同的css,则应使用CSS类。有关详细信息,请参阅此处:http://tizag.com/cssT/class.php

相关问题