William L.
William L.

Reputation: 3896

There a big blank space when hiding DIV on a form

I'm trying to hide a DIV in a form by using: document.getElementById('cost_pass').style.visibility = 'hidden';

But when I do, the form keeps a blank space where the DIV used to be, is there a way to fix this?

Upvotes: 0

Views: 475

Answers (2)

Brian Fitzpatrick
Brian Fitzpatrick

Reputation: 357

Setting visibility to hidden just hides the DIV from the page, but the space it occupies is still there (visibility doesn't affect page flow). You should look into using the Display property to hide/show your div.

https://developer.mozilla.org/en-US/docs/CSS/display

Upvotes: 0

Stormherz
Stormherz

Reputation: 376

This is not an error, visibility works that way (hiding the element, but preserving the space for it). Just try

document.getElementById('cost_pass').style.display = 'none';

Upvotes: 5

Related Questions