2

I need to escape " in a jquery string, however the " doesnt print. I am using \" to escape it.

$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

I need

 result = 'age: "12"'
1

1 Answer 1

3

You need to use html entities, eg.:

$form.append(name +' <input type="checkbox" class="team" id="team" data-value1="age:&quot;'+ age +'&quot;" data-value2="fav_color = '  + color +' "/>');
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.