One reason I follow this board is to learn how to do things I haven't
encountered. I had no idea off top of my head how to do what you want
but in quest to learn jQuery many of the problems on this board are
great for training one's self. Thanks to team jQuery for such a good
library and for excellent API docs and examples solution is very straight forward and easy to test with the markup of <p> some text <img /></p> //test example $("img").each(function() { if ($(this).parent().is("p")){ alert("My Parent is a P"); $(this).insertBefore($(this).parent()); } }); in your case you should be able to put following right after your .each(function (i) {: if ($(this).parent().is("p")){ $(this).insertBefore($(this).parent()); } ///rest of your function var a = $(this).attr('alt');............ Bruce MacKay wrote: Hi folks, |
- [jQuery] Moving a div container from within to before a p co... Bruce MacKay
- [jQuery] Re: Moving a div container from within to befo... waseem sabjee
- [jQuery] Re: Moving a div container from within to befo... infoaddicted
- [jQuery] Re: Moving a div container from within to befo... Charlie