获取一个href attr并将其设置为另一个

SMa*_*yen 0 jquery

<script type="text/javascript">
$(function() {

    $('.thelink a').select(function() {

        var a_href = $(this).attr("href");

    });
    $('.calltoActionMoreInformation a').attr('href', a_href);
});
</script>

  <div class="thelink" style="height: 250px; position: relative;">
  <a title="xxx" href="xxx">
    <img alt="tree" src="x" />

  </a>
  </div>
Run Code Online (Sandbox Code Playgroud)

试图将href从内部放入:

  <span class="calltoActionMoreInformation" style="position: absolute; bottom: 0px;">
   <a title="" href="--Link here--"></a>
  </span>
Run Code Online (Sandbox Code Playgroud)

如果我设置var a_href ='http://www.google.co.uk'; 它设置正确,所以问题在于获取.thelink div中唯一链接的href.

如何将.thelink a中的href分配给.calltoActionMoreInformation

the*_*dox 7

$('.thelink a').click(function(e) {
   e.preventDefault();
   var a_href = $(this).attr("href"); // or this.href
   $('.calltoActionMoreInformation a').attr('href', a_href);
});
Run Code Online (Sandbox Code Playgroud)

DEMO