How to append after selection

10,040

Solution 1

Use the .after() method:

$( '#test' ).after ( '<br/>' );

Solution 2

$('#test').after('<br />');

That what you are after?

Share:
10,040
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to append some code after my current selection, lets say I have this:

    <div id="test">

    </div>

    and want to append <br /> after closing div, like this

    <div id="test">

    </div>

    <br />

    Is there a way to do this?

  • Jan Hančič
    Jan Hančič over 13 years
    I removed my vote after you edited it. It was wrong, so I down voted :)
  • benhowdle89
    benhowdle89 over 13 years
    how come its still on a "-1" !?