繁体   English   中英

查找孩子并使用jQuery删除其父?

[英]Find child and remove its parent using jquery?

我可以找到孩子,但无法删除其父,这是td行

<tr><td><input type="checkbox"></td><td>Test Information</td></tr>

$(rowHtml).find('input').parent().remove();

我想要以下输出:

<tr><td>Test Information</td></tr>

尝试这个:

$(rowHtml).closest('tr').find('td:first').find('input').remove();

我已经在Jsfiddle中添加了此代码,请检查以下内容: http : //jsfiddle.net/4E5zP/1/

确保关闭表情

$(rowHtml).click(function() { $(this).parent().remove();});

我刚刚在输入元素的父类中添加了一个类名,并将其删除

             <tr><td class="inputTD"><input type="checkbox"></td><td>Test Information</td></tr>

                   $(rowHTML).find(".inputTD").remove().end();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM