title: jquery click event for each class to find href attribute
body: <p>i am new with jquery.
  i am trying to find the "href" attribute of targeted element.</p>
  
  <p>I have written a script for click event for each class "link-redirect".In this trying to select href for target element using data-target attribute.</p>
  
  <p>But by using my script i am always getting href of first div i.e "link1".</p>
  
  <p>what wrong i am doing here ?</p>
  
  <pre><code>&lt;div class="link-redirect" data-target=".title-link"&gt;
      &lt;div cass="div1"&gt;
          &lt;a href="link1" class="title-link"&gt;LInk&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="link-redirect" data-target=".title-link"&gt;
      &lt;div cass="div1"&gt;
          &lt;a href="link2" class="title-link"&gt;LInk&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="link-redirect" data-target=".title-link"&gt;
      &lt;div cass="div1"&gt;
          &lt;a href="link3" class="title-link"&gt;LInk&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="link-redirect" data-target=".title-link"&gt;
      &lt;div cass="div1"&gt;
          &lt;a href="link4" class="title-link"&gt;LInk&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
      $('.link-redirect').each(function(){
          $(this).on( "click", function() {
              var self = $(this);
              var link = $(self.data('target')).attr('href');           
              alert(link);           
          });
      });
  &lt;/script&gt;
  </code></pre>