2020-04-29 js特殊常用字符转义

JavaScript013

2020-04-29 js特殊常用字符转义,第1张

js特殊字符转义

点的转义:. ==>\\u002E

美元符号的转义:$ ==>\\u0024

乘方符号的转义:^ ==>\\u005E

左大括号的转义:{ ==>\\u007B

左方括号的转义:[ ==>\\u005B

左圆括号的转义:( ==>\\u0028

竖线的转义:| ==>\\u007C

右方括号转义:] ==>\\u005D

右圆括号的转义:) ==>\\u0029

星号的转义:* ==>\\u002A

加号的转义:+ ==>\\u002B

问号的转义:? ==>\\u003F

反斜杠的转义:\ ==>\\u005C

js中的特殊字符,加上转义符\ 。

例如:

var txt="We are the so-called "Vikings" from the north." document.write(txt) 【错误】

var txt="We are the so-called \"Vikings\" from the north." document.write(txt) 【正确】

js中的特殊字符,加上转义符\ 。

例如:

var txt="We are the so-called "Vikings" from the north." document.write(txt) 【错误】

var txt="We are the so-called \"Vikings\" from the north." document.write(txt) 【正确】