简体   繁体   English

在JavaScript代码中转义HTML字段

[英]Escaping field html within javascript code

My code is here: http://jsfiddle.net/spadez/LRFMQ/14/ 我的代码在这里: http : //jsfiddle.net/spadez/LRFMQ/14/

I tried to add two select fields to each line when hitting the add question button, so the added questions have the same fields as the initial one. 按下添加问题按钮时,我尝试在每行中添加两个选择字段,因此添加的问题与最初的问题具有相同的字段。

This is the problem bit of the code: 这是代码的问题点:

<select>
    <option value="single">Single line reply</option>
    <option value="multi">Paragraph reply</option>
</select>
<select>
    <option value="single">Required</option>
    <option value="multi">Optional</option>
</select>

It doesnt seem to like the way I have added my html form code into the javascript. 它似乎不喜欢我将html表单代码添加到javascript中的方式。 Do I need to escape it somehow? 我需要以某种方式逃脱吗?

Use a hidden div for structure and .clone it for adding. 将隐藏的div用于结构, .clone.clone以进行添加。

$("div.toClone").clone().removeClass("toClone").insertBefore(InputsWrapper);

FIDDLE 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM