Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery hide does not remove the space of the object?

Tags:

jquery

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.

like image 947
Satch3000 Avatar asked Sep 01 '25 09:09

Satch3000


1 Answers

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?

like image 165
powerbuoy Avatar answered Sep 04 '25 05:09

powerbuoy