title: Store value and reuse it in javascript oops
body: <p>I have currently 3 div and it can be more than three, Every div has one anchor tag, anchor tag have click functionality to open <code>UL</code> within the same parent. what I want is I can open <code>UL</code> and close them without effecting other one. I have made a function with oops concept but it is not working as I want. It takes two click for next anchor tag. Can it be done by oops logic or we have to choose another way. <a href="http://jsfiddle.net/2kbbgvts/" rel="nofollow">fiddle</a></p>
  
  <pre><code>$(function(){
  
      function get(){
          this.a=1;
          this.show= function(a){     
              $(this).parent().find('ul').slideDown()
          };
          this.hide= function(a){
              $(this).parent().find('ul').slideUp()
          }
      }
  
      var n= new get();
      $('a').click(function(){
          if(n.a){
              n.show.call(this)
              n.a=0;
          }
          else{
              n.hide.call(this)
              n.a=1;
          }
      });
  
  }); 
  </code></pre>