【发布时间】:2013-11-26 02:34:18
【问题描述】:
我有一个表单,如果用户点击删除,我需要删除整行。
<div id='a_<?php echo $a;?>'>
<div class='leftDesc'>Code</div>
<div class='inputText'><input type='text' name='code[]' value='<?php echo $code;?>' id='code[]'></div>
<div class='centerDesc'>Description</div>
<div class='inputText'><input type='text' name='desc[]' value='<?php echo $desc;?>' size='32' maxlength='32' id='desc[]'></div>
<div class='centerDesc'><input type='button' class='remDisp' value='Remove Code' id='removeCode_<?php echo $a;?>'></div>
</div>
当用户点击删除按钮时,我想删除整行(div a_$a)
我基本上是怎么写的:
$(this).parent().parent().remove();
【问题讨论】:
-
发布该按钮的整个处理程序
-
哈哈。这样可行。 parent.parent 似乎写得很傻。请原谅这么荒谬的问题.....
-
如果你知道父母的身份证
$(this).parents('#parent id').remove(); -
这个问题似乎是题外话,因为 OP 在他的问题中回答了他自己的问题。
-
@AlexandreDiacov 如果你知道父母的身份证,那么只需将其删除:
$('#parent_id').remove();