I think your issue is one equal sign instead of two equals signs. Basically, you are trying to set the length (which is read-only). That likely evaluates to false when it fails. Change your test to:
parnt.length==0 On Jun 20, 7:20 am, Bruce MacKay <b.mac...@massey.ac.nz> wrote: > 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(); > > > > }