p
span
output
I tried it like this, but the insertAfter is not doing it's job.
insertAfter
$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>
You forgot the last '>' in your closing tag for the $myspan variable
You have:
$myspan = "<span style='color:red'>"+$mytext+"</span";
and it should be
$myspan = "<span style='color:red'>"+$mytext+"</span>";
Best
1.4m articles
1.4m replys
5 comments
57.0k users