var txt="We are the so-called \"Vikings\" from the north."
var txt2="We are the so-called "Vikings" from the north."
document.write(txt2)
上面两种效果一样,那这两种有什么区别?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
把第一个字符串插入到HTML中时,插入的实际字符串是
反斜杠被JavaScript转义
第二个插入的是
在显示的时候浏览器会转义第二个字符串中的
"第一种后端可能会当作转义字符再次处理,第二种好