Is there a way to return the new inserted object added by the "after" or "before".
Not exactly, but after has a friend insertAfter and before has a friend insertBefore, which do the job you're after, although the signature of the methods are reversed.
Where you'd previous have had:
target.after(element);
target.before(element);
You should now have;
element.insertAfter(target);
element.insertBefore(target);
if you do :
$('.inner').after('<p>Test</p>');
you can get it by :
$('.inner').next()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With