i would usually wrap anything effected by jquery within a div <script> var obj = $(".pcontainer img"); var nav = obj.parent(); nav = nav .parent(); nav.prepend(obj); obj.remove();
</script> <div class="wrap"> <p class="pcontainer"> <img src="coffee.jpg" border="0" /> </p> </dvi> On Sat, Jun 6, 2009 at 11:11 PM, Bruce MacKay <b.mac...@massey.ac.nz> wrote: > Hi folks, > > The following function takes an image tag (or table) that appears within a > p tag container in the form > < p> <img> text < /p> > > and wraps the image (and caption if a title is present) into a div for > floating left, right, or centering. > > My problem is that I don't know how to shift the processed image from > within the p container to immediately before it (so that the created div is > not within a p container) > > I'd appreciate help in this next step. > > Thanks, > > Bruce > > function fnDoImages() { > > $('img.imgposl,img.imgposr,img.imgposc,img.tblposl,img.tblposr,img.tblposc').each(function(i) > { > var a = $(this).attr('alt'); > var q = $(this).attr('class').substr(0,3); > var p = $(this).attr('class').substr(6); > var t = $(this).attr('title'); > var w = $(this).attr('width'); > if (a.length=0) { > $(this).attr('alt',''+t+''); > } > $(this).wrap("<div class='buggybox clearfix' > id='g"+i+"'></div>"); > if (q=='tbl' && t.length>0) { > $(this).before("<p class='imgcaption' > style='width:"+w+"px;'>"+t+"</p>"); > } else if (t.length>0){ > //$(this).after("<p class='imgcaption' > style='width:"+w+"px;'>"+t+"</p>"); > }; > $("#g"+i).addClass("img"+p).css({width:w+'px'}); > }); > > } >