Thursday, May 12, 2022

[FIXED] How can I add an element after another element?

Issue

I have a certain textbox and I want to add a div after it. I've tried the .append() function, but that only adds the div in the element.

For example, I have:

<input type="text" id="bla" />

and I want to change that into:

<input type="text" id="bla" /><div id="space"></div>

Solution

try using the after() method:

$('#bla').after('<div id="space"></div>');

Documentation



Answered By - Rowan
Answer Checked By - Cary Denson (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.