如何在 J 查询中保留特殊字符

How to keep special characters in J-query?

本文关键字:保留 特殊字符 查询      更新时间:2023-09-26

我的jquery字符串具有如下特殊字符。

$(window).load(function() {  
  var text = 'Hi there, I'm 5'5" height';
  alert (text); // out put without ' " signs
});

我想打印与输出相同的输出。怎么办?在PHP它通过htmlspecialchars功能来实现。所需输出为

Hi there, I'm 5'5" height
您需要

使用'转义引号

  var text = 'Hi there, I''m 5''5'" height';
  alert (text); // out put without ' " signs