Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prepend after element

Tags:

jquery

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>');
like image 379
Scarface Avatar asked Jan 21 '23 07:01

Scarface


1 Answers

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

$('#test').after('<a id="test2">test2</a>');
like image 73
Nick Craver Avatar answered Feb 05 '23 02:02

Nick Craver