i have a div that is hidden.After calling a function i just give the code as follows for making the div visible.
the code is document.getElementById("divid").style.display="block";
it works in IE but not in Mozilla(3.0.3)

have any idea?
thanx in advance...

Recommended Answers

All 3 Replies

If you have a floating elements next to --> document.getElementById ("divid"); just simply add this up -->

document.getElementById ("divid").style.display="block";
document.getElementById ("divid").style.float= "left"; 
/* It's up to you to set things up wheather it's left, right or center floated */
document.getElementById ("divid").style.clear= "both";

try using the visibility property.

to make it visible:

document.getElementById ("divid").style.visibility="visible";

to make it back to hidden:

document.getElementById ("divid").style.visibility="hidden";

Regards,
ivanceras

Using the "visibility" property only hides the element, but the space it uses will still be taken up and leave a blank gap in the page.

The easiest way to hide/open a DIV is:

<a href="#" onclick="var myBox=document.getElementById('myDiv');myBox.style.display=(myBox.style.display=='none' ? 'block': 'none');return false;">Hide or Show Box</a>

<div id="myDiv">this will open or close</div>
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.