How to append
to the end of the last tag with jQuery?
For example, my html would be something like this:
<div>
<p>line1</p>
<p>line2</p>
</div>
I want the end result to be:
<div>
<p>line1</p>
<p>line2 </p>
</div>
How to append
to the end of the last tag with jQuery?
For example, my html would be something like this:
<div>
<p>line1</p>
<p>line2</p>
</div>
I want the end result to be:
<div>
<p>line1</p>
<p>line2 </p>
</div>
Share
Improve this question
edited Jul 30, 2013 at 18:32
Joe
15.6k8 gold badges51 silver badges57 bronze badges
asked Jul 30, 2013 at 18:28
hardy1337hardy1337
231 silver badge5 bronze badges
1
- You might want to consider just using the :last-child class (not available in ie6, ie7, ie8, available in ie9 and good browsers) and just adding some slight right-margin instead of adding content. – Kzqai Commented Jul 30, 2013 at 18:59
1 Answer
Reset to default 7Like this:
$("div p:last").append(" ");
See here:
http://jsfiddle/d8AGr/