useranon
useranon

Reputation: 29514

Hide Other DIvs other than the One i have clicked ... In JQuery

HI,

i am having html like

 <div class="float_left myFormsContainer" id="fm_myforms_container">

     <div id='form1'>
           <p>
             <a id="form43" data-attr="Formentries" href="#">  Personal Form </a>
           </p>
      EDITTED     <div></div>
      </div>
  <div id='form2'>

       <p>
             <a id="form44" data-attr="Formentries" href="#">  Contact Form </a>
         </p>
 </div>

 <div id='form3'>
             <p>
             <a id="form45" data-attr="Formentries" href="#">  Employee Form </a>
         </p>
</div>

</div>

In JQuery i have coded like on clicking any a tag

    $("#fm_myforms_container a").live("click", function(){


        $("#fm_myforms_container div").hide();//to hide all other divs other than the one what i have clicked...

return false;
      });

i am trying to hide all other divs other than the one what i have clicked...

how to do ?? please suggest me.. I am new to JQuery ...

Upvotes: 0

Views: 241

Answers (1)

Philippe Leybaert
Philippe Leybaert

Reputation: 171774

You could use:

$("#fm_myforms_container div").not($(this).closest("div")).hide();

or if you only want hide the top-level divs:

$("#fm_myforms_container > div").not($(this).closest("div")).hide();

Upvotes: 1

Related Questions