简体   繁体   中英

Find child and remove its parent using jquery?

I'm able to find the child but can not remove its parent, which is the td row

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

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

I would like the following output:

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

try this:

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

I have added this code in Jsfiddle check this: http://jsfiddle.net/4E5zP/1/

确保关闭表情

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

I just added a class name to the parent of the input element and remove it

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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