mlzboy
mlzboy

Reputation: 14691

how to build dom object into html with jquery

i tried to use this

$("#aa").insertAfter($("<input type='text' name='category' value='h2' /\>"));

it seems didn't work for me

Upvotes: 1

Views: 122

Answers (1)

Nick Craver
Nick Craver

Reputation: 630389

You want to use .after() here, like this:

$("#aa").after("<input type='text' name='category' value='h2' /\>");

.insertAfter() is the opposite, it takes the first element and tries to place it after the second element (or selector, whichever you give it), so it would look like this:

$("<input type='text' name='category' value='h2' /\>").insertAfter("#aa");

Upvotes: 3

Related Questions