Replace multiple
's with only one

前端 未结 9 2131
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 12:55

How do I use JavaScript to detect




to become one


?

I trie

9条回答
  •  无人共我
    2021-02-01 13:13

    Try this

    $('body').html($('body').html().replace(/(
    )+/g,"
    "));

    It will replace n number of
    into one.

    Demo

提交回复
热议问题