title: get the href value by clicking on anchor in multiple anchors using jquery
body: <p>i'm trying to get the href value in multiple links or tag a.and i tried with this code     </p>
  
  <pre><code>var val;
  $(document).ready(function() {
      $("a").click(function() {
          window.val = $(this).attr("href");
          alert(window.val);
      });
  </code></pre>
  
  <p>it is working fine for the multiple links and which is inside the file that is local, here few demo links </p>
  
  <pre><code>&lt;a href="sometext1"&gt;a&lt;/a&gt;
  &lt;a href="sometext2"&gt;b&lt;/a&gt;.....
  </code></pre>
  
  <p>but problem is i want that href value globally available because i'm using that in other file . My problem is how to make it global, or is there any other way to do it.</p>
  
  <p>and how to write our own function to work the same thing without using $(document).ready function.</p>
  
  <p>this whole thing in one html page but i want only href value in other html page , so if we write our own js function we can use this in both html pages . And that function should return href. but here i dono how to return to $(document).ready function.</p>