henryaaron henryaaron - 1 month ago 5
jQuery Question

jQuery add ID to parent table then remove TD

I have a TD with an image nested inside it, I want to add an ID to it's parent and then have that TD removed. The following code will remove the TD based on the image that is nested inside it, but before it's removed, I want to add an ID to it's parent table. Any suggestions?

$('td img[src="/v/vspfiles/templates/cyberfront/images/RBox_Border_Left_Top.gif"]').parent().remove();

Answer
$('td img[src="/v/vspfiles/templates/cyberfront/images/RBox_Border_Left_Top.gif"]').parent().closest("table").attr('id','newId');

$('td img[src="/v/vspfiles/templates/cyberfront/images/RBox_Border_Left_Top.gif"]').parent().remove();
Comments