jQuery insertAfter not working -


i have set of buttons:

  <div id="button">       <button id="show_link_group">show links</button>       <button id="show_contact_group">show contacts</button>       <button id="show_update_group">show updates</button>       <button id="show_activity_group">show action items</button>   </div> 

and trying insert div after it:

<div id="link_group">        <p1>adsfadsf</p1> </div> 

it supposed insert after click button id="show_link_group":

$('#show_link_group').click(function() {   $("<div id='link_group'").after('<div id="button"></div>'); }); 

when click it, doesn't anything. followed documentation:

http://api.jquery.com/insertafter/

what doing wrong??

thanks!

you have use selector specify insert, not html string.

$("<div id='link_group'><p1>asdfasdf</p1></div>").insertafter("#button"); 

if link_group div in dom, can do:

$("#link_group").insertafter("#button"); 

this move current location after button.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -