本文介绍了display:none;在浏览器中显示“none”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

适用于Google Chrome,但在Internet Explorer中,当关闭图标被点击时,浏览器删除弹出元素,但导致在浏览器窗口中显示文本无。请解释我如何解决此问题。

This jsFiddle example works in Google Chrome, but in Internet Explorer then when the close icon is clicked the browser removes the pop-up element but results in the text 'none' being displayed in the browser window. Please explain how I can resolve this issue.

HTML:

<div id="popup">
    <!-- Close popup link -->
    <a href="javascript:document.getElementById('popup').style.display='none';">X</a>
</div>


推荐答案

使用onclick代替href

Use onclick for the event handler instead of href http://jsfiddle.net/AE2X3/4/

<div id="popup">
        <a href="#" onclick="document.getElementById('popup').style.display='none';return false;" id="close_popup"></a>
        <p>This is a pop-up.</p>
</div>

这篇关于display:none;在浏览器中显示“none”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 22:55