>From the insertAfter docs: 
http://jquery.bassistance.de/api-browser/#insertAfterContent

$("p").insertAfter("#foo");  (Same as $("#foo").after("p"))

Instead of inserting content, such as your div tags, after the selected
element, it inserts all of the matched elements after the given element,



Yansky wrote:
> 
> Thanks Daemach & John. Both examples work fine. :)
> 
> Just one last thing, I'm still a bit fuzzy on the difference between
> .after() and insertAfter(). I've gone through the documentation a number
> of times, but they still seem to do the same thing (albeit the latter in
> reverse). 
> 
> 
> 
>> .after() inserts the HTML after each link, whereas .insertAfter()
>> inserts the link after each block of HTML. (An important distinction.)
>> 
> 
> Could you (or anyone else) expand on this explanation a bit please?
> 
> Danka. :)
> 
> 
> 
> 
> 
> John Resig wrote:
>> 
>> I think something like this will get you your desired result:
>> $("a:not([EMAIL PROTECTED])").after("<div><p>Lorem Ipsum</p></div>");
>> 
>> .after() inserts the HTML after each link, whereas .insertAfter()
>> inserts the link after each block of HTML. (An important distinction.)
>> 
>> More information can be found here:
>> http://docs.jquery.com/DOM/Manipulation
>> 
>> --John
>> 
>> On 3/5/07, Yansky <[EMAIL PROTECTED]> wrote:
>>>
>>> I'm trying to insert a div after all < a > elements that don't link to
>>> my
>>> site. My script is currently working like this:
>>>
>>> var getLinks = $("a").not($("[EMAIL PROTECTED]"));
>>> for(i=0;i<getLinks.length;i++){$("<div><p>Lorem
>>> Ipsum</p></div>").insertAfter(getLinks[i]);}
>>>
>>> but I'm having trouble converting it all to jQuery using ".each":
>>>
>>> $("a").not($("[EMAIL PROTECTED]")).each(function()
>>> {$(this).html("<div><p>Lorem Ipsum</p></div>").insertAfter();});
>>>
>>> The function only gives the raw DOM right? Not the jQuery object. So I
>>> have
>>> to use $(this) to access the jQuery objects again right?
>>>
>>> At the moment, the ".each" version inserts the div as a child node,
>>> rather
>>> than as a sibling (which is what I'm after).
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Help-with-%22.each%22-tf3351407.html#a9319633
>>> Sent from the JQuery mailing list archive at Nabble.com.
>>>
>>>
>>> _______________________________________________
>>> jQuery mailing list
>>> discuss@jquery.com
>>> http://jquery.com/discuss/
>>>
>> 
>> _______________________________________________
>> jQuery mailing list
>> discuss@jquery.com
>> http://jquery.com/discuss/
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Help-with-%22.each%22-tf3351407.html#a9320644
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to