【发布时间】:2012-10-17 11:18:20
【问题描述】:
您好,我正在尝试编写代码来显示隐藏评论 ID 特定的文本区域。
我已经成功地为页面加载时的每个评论分配了一个文本区域,然后在点击时隐藏和显示。但我不知道如何再次隐藏它们。到目前为止,这是我想出的:
$('#show-reply-comment').each(function(){
$(this).click(function(e){
e.preventDefault();
var commentid = $(this).data('commentid');
$('#'+commentid+'').show();
$(this).unbind('click');
$(this).attr('id', 'hide-reply-comment');
});
});
$('#hide-reply-comment').each(function(){
$(this).click(function(e){
e.preventDefault();
var commentid = $(this).data('commentid');
$('#'+commentid+'').hide();
$(this).unbind('click');
$(this).attr('id', 'show-reply-comment');
});
});
用户应该能够同时打开多个评论回复文本区域。如果有人能给我关于如何继续的提示,将不胜感激。
编辑:我忘了返回 false;但我不想弄乱代码
【问题讨论】:
标签: jquery