Trying to make icon hidden in IE9 with compatability mode

I am trying to make an icon invisible when it is clicked, my HTML looks like this:

<img id="imgTop" style="border-width:0px;" src="../Images/Common/button-print-icon.gif" onclick="clicked()">

and the Javascript looks like this:

function clicked()
{
    document.getElementById("imgTop").hidden="";
    .....
}

This works fine in Firefox and Chrome, but in IE 9 with compatibility mode it doesn't. I tried using several other methods (Such as passing this and using CSS style display), but nothing seems to work, can anyone help?

Answers


You have to options visibility:hidden; or display:none;

Display None - Example

function clicked() {
    document.getElementById("imgTop").style.display = "none";
}

Visibility Hidden - Example

function clicked() {
    document.getElementById("imgTop").style.visibility = "hidden";
}

The difference between visibility hidden and display none:

visibility: hidden hides the element, but it still takes up space in the layout.

display: none removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.

Source


Need Your Help

asm (fpu) normalize - how to optimize it

assembly x86 sse fpu

I have written some x86 asm - fpu routine to

How to do logging.DEBUG in django code?

python django debugging logging django-settings

In django we have settings.py that defines the DEBUG for the whole project.