如何动态删除指定的td

图片说明
当我点击删除按钮时,需要删除掉input对应的td和删除按钮对应的td。

要有dom结构,如果是下面的用这个,不是自己注意修改js的层次调用代码

 <td><input type="text"><a onclick="this.parentNode.parentNode.removeChild(this.parentNode)">x</a></td>

从删除按钮自身出发,获取到前面的input框,用js或者jq实现删除

$(this).parents("td").prev().remove();
$(this).parents("td").remove();

$(this).parents("td").prev().remove();
$(this).parents("td").remove()

$(this).parents("td").prev().remove();
$(this).parents("td").remove()