parnt.length isn't zero so if you are still using that test  could the the problem

think about it a second, if you assign $(this).parent() to it how can length be zero?
also you have a syntax error

$(this).insertBefore(p)// should have quotes around p unless it is a variable
if you aren't using firebug it's very worth installing

in firebug get an error p not defined,

firebug lets you test code right in console of  FF, also you can see the live html changes that are made by jquery


Bruce MacKay wrote:
Thanks Mauricio, I hadn't tried that angle, but unfortunately it didn't make any difference.

I've also tried adding a class to the initial parent p and then trying to remove all paragraphs containing that class name - and have achieved the same nil outcome.

Thanks for your input.

Cheers, Bruce


At 11:40 p.m. 20/06/2009, you wrote:
How about?
 
$('.buggybox').next('p').remove();
 
Maurício
-----Mensagem Original-----
De: Bruce MacKay
Para: jquery-en@googlegroups.com
Enviada em: sábado, 20 de junho de 2009 08:20
Assunto: [jQuery] Removing an emptied paragraph from the DOM

Hello folks,

I have an application which removes an image from within a paragraph, wraps that image in a div and places it in front of the paragraph.

I now want to remove that paragraph.

Why doesn't the following use of remove() not achieve my objective?  I've tested the length - it is 0, yet the remove doesn't happen.

Thanks, Bruce


var parnt = $(this).parent();            //the parent p tag containing the image to be processed
$(this).insertBefore(p).wrap("<div class='buggybox clearfix' id='g" + i +"'></div>");

if (parnt.length=0) {
         parnt.remove();
}

Reply via email to