I have this jQuery code:
function test(){
var $h=$('<h2>').text('title')
$p=$('<p>').text('sample'),
$result=$h.after($p);
return $result;
}
I expect when i show the $result
in the page, it be:
<h2>title</h2><p>sample</p>
But it is:
<h2>title</h2>
How should i change the code to solve this issue?
Edit1:
I want return this result by calling test()
function and i wont use any parnet element in the function or as a parameter. Realy i want return this collection of jQuery elements!
and
siblings. i.e. you have to define a parent object and return that object.
– Jose Faeti Oct 25 '16 at 13:52