Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide all children DOM elements until found a <hr/>

Tags:

jquery

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();
});
like image 581
Kandinski Avatar asked Dec 21 '22 10:12

Kandinski


1 Answers

Use this: $('.row-father > hr:first').prevAll(':not(legend)').hide(); See http://api.jquery.com/prevall/

like image 84
tvanfosson Avatar answered Dec 28 '22 23:12

tvanfosson