Remove non breaking space ( ) from between elements using jquery

前端 未结 1 1045
走了就别回头了
走了就别回头了 2021-01-07 09:14

How can I use jquery to remove non-breaking spaces (nbsp) which appear between html elements?

So, for example, the following code is generated by a cms:



        
相关标签:
1条回答
  • 2021-01-07 09:37
    var div = "<div><span>content</span>&nbsp;<span>content</span></div>";    
    var newdiv = div.replace(/&nbsp;/g,'');
    

    demo

    0 讨论(0)
提交回复
热议问题