Satch3000 Satch3000 - 5 months ago 6x
Javascript Question

JQuery hide does not remove the space of the object?

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
seems to hide the element but the space for it is still allocated.

Is there a way to remove this space... like
on CSS does?

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

Edit: Have you checked with Firebug (or similar) what actually happens to the element?