Reputation: 3896
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
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
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