<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 ?
$('.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)
| 归档时间: |
|
| 查看次数: |
175 次 |
| 最近记录: |