I wonder how to hide all elements until found the first <hr/>. Then the loop should stop
<div class='row-father'>
<legend> Title here </legend>
<div class="row-fluid">...</div>
<div class="row-fluid">...</div>
<hr/>
<div class="row-fluid">...</div>
<div class="row-fluid">...</div>
<div class="row-fluid">...</div>
<div class="row-fluid">...</div>
<hr/>
<div class="row-fluid">...</div>
<div class="row-fluid">...</div>
<hr/>
</div>
…
$('.row-father').find('*').each(function(){
if ($(this) != '<hr/>')
$(this).hide();
});
Use this:
$('.row-father > hr:first').prevAll(':not(legend)').hide();See http://api.jquery.com/prevall/