string.replace() not replacing ALL

This question already has an answer here:

  • How to replace all occurrences of a string in JavaScript? 41 answers

  • Use:

    value.replace(/+/g, ' ')
    

    g is a global match flag and will cause your replace to match all instances of + .


    Try ...

    $("#edit_order #"+key).val(value.replace(/+/g,' '));
    

    To replace all, your value "to replace" must be defined as a regular expression.

    Here's a jsFiddle

    链接地址: http://www.djcxy.com/p/16852.html

    上一篇: 从另一个表中更新行

    下一篇: string.replace()不会取代ALL