Reputation: 11
I have a span inside a div as follows.
<div class="class a" align="Right">
<span id="Last_Name">Last Name</span>
Text outside Span
</div>
I would like insert another span after "Text outside Span".
When I try $("#Last_Name").after(HtmlText); , the html is inserted before "Text outside span"
Upvotes: 0
Views: 635
Reputation: 5810
Try .append("HTML OR Text")
to append text in element, which always appends Text or HTML at last, before ending of that particular element.
$(".class.a").append("<span class='newSpan'>Another Span at before ending of element.</span>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="class a" align="Right">
<span id="Last_Name">Last Name</span>
Text outside Span
</div>
Upvotes: 1