admin管理员组文章数量:1026125
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/
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/
本文标签: javascriptHow to append ampnbsp inside the last ltpgt tag with jqueryStack Overflow
版权声明:本文标题:javascript - How to append &nbsp inside the last <p> tag with jquery? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745633118a2160281.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论