replace如果替换数据时,默认只替换第一个。

  如果在替换的时候加上: / 替换内容 /g 就能实现全部替换

  例如:

function change(strvalue){
strvalue = strvalue.replace(/&/g,"&");
strvalue = strvalue.replace(/&lt;/g,"<");
strvalue = strvalue.replace(/&gt;/g,">");
strvalue = strvalue.replace(/&quot;/g,""");
strvalue = strvalue.replace(/'/g,"'");
return strvalue;

相关文章:

  • 2021-11-07
  • 2021-07-22
  • 2022-02-11
  • 2021-05-10
  • 2022-01-04
  • 2021-11-06
  • 2021-09-12
  • 2021-11-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
相关资源
相似解决方案