how can remove backslash in value by jQuery?

后端 未结 3 1910
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 18:08

if $(this).val() have backslash remove backslash in it by jQuery. how is it? 1111\\/11\\/11 -> 1111/11/11

相关标签:
3条回答
  • 2021-02-19 18:50

    Try this.

    $(this).val($(this).val().replace(/\\/gi, ""));
    
    0 讨论(0)
  • 2021-02-19 18:57
    var str = $(this).val().replace('/','');
    
    0 讨论(0)
  • 2021-02-19 18:58
    $(this).val().replace(/\\/g, '');
    

    You have to use two backslashes to get the \ character. A single backslash is used for control characters such as \r \n etc. Using the double backslash escapes this and gives you what you want.

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