1.11M Members

How to Hide and Unhide Div tag in IE7 and IE8

 
0
 

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

 
0
 

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;
  }
}
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: