I am using some jQuery code where I hide a list item...
$("ul.items").each(function() {
$("li:gt(4)", this).hide();
My problem is that .hide
seems to hide the element but the space for it is still allocated.
Is there a way to remove this space... like display:none
on CSS does?
UPDATE: .hide
is actually taking away the element but the other elements are not stretching up to take the missing space left by the element.
Hmm that shouldn't happen. $.fn.hide()
sets display: none;
not visibility: hidden;
or opacity: 0;
(which would hide the element but keep its space occupied).
"This is roughly equivalent to calling .css('display', 'none'), except that the value of the display property is saved in jQuery's data cache so that display can later be restored to its initial value" - from http://api.jquery.com/hide/.
Edit: Have you checked with Firebug (or similar) what actually happens to the element?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With