javascript - How to append &nbsp inside the last <p> tag with jquery? - Stack Overflow

How to append to the end of the last tag with jQuery?For example, my html would be something like th

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 &nbsp;</p>  
</div>  

How to append &nbsp; 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 &nbsp;</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
Add a ment  | 

1 Answer 1

Reset to default 7

Like this:

$("div p:last").append("&nbsp;");

See here:

http://jsfiddle/d8AGr/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745633120a4637226.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信