我需要逃避"在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"'
答案 0 :(得分:3)
您需要使用html实体,例如:
$form.append(name +' <input type="checkbox" class="team" id="team" data-value1="age:"'+ age +'"" data-value2="fav_color = ' + color +' "/>');