Dear Friends,

The problem I am facing a that how to Hide and Unhide Div tags in IE7 and IE8?

My code is

<div>
                            <a href='javascript:void(0)' onclick='DisplayAddComment();'>
                                <img src="../images/AddComment.jpg" border="0"/>
                            </a>
                        </div>

and javaScript Function is

var m=1;
            function DisplayAddComment()
            {
                if(m==1)
                {
                    document.getElementById("dvAddComments").style.visibility="visible";
                    document.getElementById("dvAddComments").style.display="table";
                    m=0;
                }
                else
                {
                    document.getElementById("dvAddComments").style.visibility="hidden";
                    document.getElementById("dvAddComments").style.display="none";
                    
                    m=1;
                }
            }

This code is working in all most available Browsers.
Only IE creates the problem.

Thanks in Advance.

Sumit Joshi

Sumit:

IE has problem with dynamic setting 'visibility' style property. What you may do is to use CSS instead.

<style type="text/css">
.showDisplay {
  display: table;
}
.hideDisplay {
  display: none;
  visibility: hidden;
}
</style>

// javascript part
...
var m=1;
function DisplayAddComment() {
  if(m==1) {
    document.getElementById("dvAddComments").className = "showDisplay"
    m=0;
  }
  else {
    document.getElementById("dvAddComments").className = "hideDisplay"
    m=1;
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.