function htmlEscape(str) {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
var path = '<div>hello world</div><p>&nbsp;</p>';
var res = htmlEscape(path);
console.log(res);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-19
  • 2021-10-06
  • 2022-01-19
  • 2022-02-27
  • 2021-08-24
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2021-10-13
  • 2021-10-14
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案