- I have a
p
Element and try to wrap it inside aspan
. - then insert it after the
p
tag with the idoutput
.
I tried it like this, but the insertAfter
is not doing it's job.
$mytext = $("p#test").html();
$myspan = "<span style='color:red'>"+$mytext+"</span";
$($myspan).insertAfter("p#output");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id="test">Test</p>
<p id="output">OUTPUT:</p>
See Question&Answers more detail:os