【发布时间】:2016-09-17 19:52:52
【问题描述】:
我需要在 jquery 字符串中转义 ",但是 " 不打印。我正在使用 \" 来逃避它。
$form.append(name +' <input type="checkbox" class="team" id="team"
data-value1="age:'+ age +'" data-value2="fav_color = ' + color +' "/>
$form.append(name +' <input type="checkbox" class="team" id="team"
data-value1="age: \"'+ age +' \"" data-value2="fav_color = \"' + color +' "\"/>
result = 'age: 12' for both
我需要
result = 'age: "12"'
【问题讨论】:
-
我认为你必须使用 html 编码版本的引号而不是转义它们:stackoverflow.com/questions/7260195/…
标签: javascript jquery