获取链接href并将其应用到另一个jQuery链接 [英] Get link href and apply it to another link jQuery
本文介绍了获取链接href并将其应用到另一个jQuery链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一组DIV,每个DIV都包含一张图像,周围包裹着一个空的锚标签
I have a set of DIVs, each contains an image with an empty anchor tag wrapped around it
<a href="#"> Image is here </a>
然后在div关闭之前我有一个 '继续阅读' 链接
I then have a 'Continue reading' link just before the div closes
<a href="?p=453">Continue reading <span class="meta-nav">→</span></a>
使用jQuery的一种方式,当页面加载时,我可以 继续阅读 按钮的href
位置,并将空锚应用到周围我的形象?
Is there a way with jQuery that when the page loads, I can that the href
location of the continue reading button and apply that the empty anchor wrapped around my image?
演示: http://jsfiddle.net/2hu66/1/
推荐答案
$('.card-prod').each(function() {
var cr = $(this).find('a:last');
$(this).find('.cardclick').attr('href', cr.attr('href'));
});
示例小提琴: http://jsfiddle.net/2hu66/4/
这篇关于获取链接href并将其应用到另一个jQuery链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文