how can i get the attribute (href) of a link that is in the same div as another element , see the example below:
<div id="wrap">
<div id="column1">
<div class="desc">Some stuff</div>
<a href="#1" class="url link1">Link1</a>
</div>
<div id="column2">
<div class="desc2">Another Some stuff</div>
<a href="#" class="url link2">Link2</a>
<div>
</div>
<div id="wrap">
<div id="column1">
<div class="desc">Some stuff</div>
<a href="#2" class="url link1">Link1</a>
</div>
<div id="column2">
<div class="desc2">Another Some stuff</div>
<a href="#" class="url link2">Link2</a>
<div>
</div>
When i click LINK2 of the first wrap div , jQuery get the href of link1 of the first wrap div.
I know we can get the href using .attr() in jQuery but how can i archive this using jQUery?
Lets say you get the current
<a>element (Link 2) which has been clicked using$(this), you can get Link1 using this:alert( $(this).parent().prev().find('a.link1').attr('href') );