[英]Remove a td based on its content with jQuery
我有一个td
里面有一个图像我想根据里面的图像目录删除整个td
。 源代码:
<td width="1" valign="top"><img src="/PBox_Border_Right_Top.gif" alt=""></td>
所以我一直在寻找类似的东西
td:contains img[src=image/source.gif].remove()
$('td img[src^="directory"]').parent().remove();
尝试这个:
$('td:has(img[src^="/path/to/remove"])').remove();
您可以使用.has()或:has
这是一个例子: http : //jsfiddle.net/2xANA/1/
has()参考: http : //api.jquery.com/has/
$("td:has(img[src='image/source.gif'])").remove();
$('td').children('img[src^="image/"]').remove();
这将选择所有直接作为td元素子元素的图像元素,并具有以image/
开头的src
属性(图像将通过.remove()
函数调用删除)。 您可以将image/
更改为想要选择所需图像目录的任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.