How to replace \n with
in JavaScript?

后端 未结 10 2099
面向向阳花
面向向阳花 2020-12-31 00:44

I have a textarea where I insert \\n when user presses enter. Code from this textarea is sent to a WCF service via jQuery.ajax(). I cannot save

10条回答
  •  醉梦人生
    2020-12-31 01:20

    you can use javascript built in replace function with a little help of regex, for example

    $('#input').val().replace(/\n\r?/g, '
    ')

    this code will return all enters replaced with

提交回复
热议问题