Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery select div below parent div

I have a few divs set up like so:

 <div class="menu_options">
    <div class="parent_div">input field</div>
    <div class="children_div">
        <div class='something">field</div>
        <div class="something_else">field</div>
    </div>
 </div>

<div class="menu_options">
    <div class="parent_div">input field</div>
    <div class="children_div">
        <div class='something">field</div>
        <div class="something_else">field</div>
    </div>
 </div>

<div class="menu_options">
    <div class="parent_div">input field</div>
    <div class="children_div">
        <div class='something">field</div>
        <div class="something_else">field</div>
    </div>
 </div>

in jquery i am doing

        $('.parent_options').each(function() {
            $(this).click(function() {

            });
        });

right now $(this) is giving me the parent_div that i clicked on and I need to be able to move down to the children_div and hide the entire children_div. Any ideas. I know in prototype i used a down function but not sure if jquery has it.

like image 980
Yeak Avatar asked Oct 23 '25 20:10

Yeak


1 Answers

If you want to hide .children_div after clicking on .parent_div use

  $('.parent_div').click(function() {
        $(this).siblings(".children_div").hide();
  });

Demo here

like image 60
Bruno Avatar answered Oct 25 '25 12:10

Bruno