2011-07-27 94 views
1

我需要在用户点击链接时显示一些文本,然后在点击链接后删除链接。如何删除链接?

这里举例:http://jsfiddle.net/HCAfz/2/

如何删除从页面被点击并保持上述行为的联系,与隐藏的div被显示?

+0

将要删除点击时出现'a'标签?还有内容? – PeeHaa

回答

1

要c ompletely删除链接做:

$('a.yourLink').click(function(event) { 
    $(this).next('.hiddenDiv').show(); 
    window.open(this.href, '_blank'); 
    $(this).remove(); 

    return false; 
}); 

要隐藏的链接做到:

$('a.yourLink').click(function(event) { 
    $(this).next('.hiddenDiv').show(); 
    window.open(this.href, '_blank'); 
    $(this).hide(); 

    return false; 
}); 

注意,我在event.preventDefault();代替做return false;event.stopPropagation();,因为它是一样的

1

你需要更好地解释自己,但最简单的情况下加入这一行:

$(this).hide(); 
1

我想你需要这个

$('a.yourLink').click(function(e) { 
     e.preventDefault(); 
     $(this).hide().next('.hiddenDiv').show(); 
     window.open(this.href, '_blank'); 
});