这是我上一个问题的第二部分。下面是标记:
html
<a data-message="my message" href="www.site.com">click here</a>
<div class="new-window">
<p>(my message)</p>
<a href="LINK-GOES-HERE">proceed</a>
</div>js
$('a[data-message]').click(function(){
$('.new-window').fadeIn(300);
$('.new-window p').text($(this).data('message'));
return false;
});因为页面上有几个链接,我想要一个自定义的div窗口(而不是一个标准的警报)来显示一个消息和传递给new-window的url。有没有办法将所选链接的URL传递给新窗口?
谢谢
发布于 2013-04-03 23:26:15
之后:
$('.new-window p').text($(this).data('message'));添加:
$('.new-window a').attr('href', $(this).attr('href'));发布于 2013-04-03 23:23:15
$('.new-window p').text( this.href );发布于 2013-04-03 23:23:23
这可能会有所帮助:
$('a[data-message]').click(function(){
console.log($(this).attr('href'));
$('.new-window').fadeIn(300);
$('.new-window p').text($(this).data('message'));
return false;
});https://stackoverflow.com/questions/15791418
复制相似问题