views:

25

answers:

1

This is probaby really easy for you guys. Its a real hassle for me..

I want to add a new link next to all of my other links.

Could someone help me out? Please!? http://jsfiddle.net/Ahndm/

+1  A: 

Instead of $("a") in your loop, use this to reference the current element, like this:

$(this).after("<span> <a href='" + newURL + "" + ID + "'>"+ newPlace + "</a></span>");

Here's the updated/working demo. Any time you're inside a .each() you can use this which is the current DOM element, using $("a") selects all anchors, creating n^2 links.

Nick Craver
Oh my god. Thank you! I cant belive how stupid i am.
alfred
@alfred - You asked a question, setup a demo and laid out what you wanted very clearly. That's not stupid at all, you know how to seek help and ask questions, that's years beyond most programmers :)
Nick Craver