我需要在用户点击链接时显示一些文本,然后在点击链接后删除链接。如何删除链接?
这里举例:http://jsfiddle.net/HCAfz/2/
如何删除从页面被点击并保持上述行为的联系,与隐藏的div被显示?
我需要在用户点击链接时显示一些文本,然后在点击链接后删除链接。如何删除链接?
这里举例:http://jsfiddle.net/HCAfz/2/
如何删除从页面被点击并保持上述行为的联系,与隐藏的div被显示?
要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();
,因为它是一样的
'.hide()'会在这里更有意义,或'.remove' –
你说得对。旧的光秃秃的骨头DOM习惯很难消退。 :P –
你需要更好地解释自己,但最简单的情况下加入这一行:
$(this).hide();
我想你需要这个
$('a.yourLink').click(function(e) {
e.preventDefault();
$(this).hide().next('.hiddenDiv').show();
window.open(this.href, '_blank');
});
将要删除点击时出现'a'标签?还有内容? – PeeHaa