title: how to get text from hidden input element nested in a div
body: <p>I have the following html code:</p>
  
  <pre><code>&lt;a class="tog" href="#"&gt;Click Me&lt;/a&gt; 
  &lt;div class="result"&gt;
      &lt;input type="hidden" name="hid" value="val01" /&gt;
      This is a container div
  &lt;/div&gt; &lt;br /&gt;
  &lt;a class="tog" href="#"&gt;Click Me&lt;/a&gt; 
  &lt;div class="result"&gt;
      &lt;input type="hidden" name="hid" value="val02" /&gt;
      This is a another container div
  &lt;/div&gt;
  </code></pre>
  
  <p>How can I get value from hidden input on click of <code>&lt;a&gt;</code>? I am trying with this jquery code but it is failing to retrieve value from those hidden input element.</p>
  
  <pre><code>$(document).ready(function(){
   $(".tog").click(function(){
     var $this=$(this);
   if (!$this.next(".result").data('loaded')){ 
     alert($this.next("input[name=hid]").val());
    }
   });
  });
  </code></pre>