tags:

views:

31

answers:

1

Is it possible to prepend after a certain element? For example, I am prepending a hyperlink to a div however there is already an element in there represented as <a id="test">test1</a> Is it possible to prepend the test2 hyperlink after the test1 hyperlink?

  $('div[id='+id+']').prepend('<a id="test">test2</a>');
+1  A: 

You can use .after() to place it after the other element, like this:

$('#test').after('<a id="test2">test2</a>');
Nick Craver
Thanks a lot Nick, appreciate it
Scarface