jQuery variable within string, quotes within quotes

jquery

Solution

try `\"` instead of `'` in `onClick`:

$(".container").append("<a href='javascript:void(0)' onClick=\"showField('"+data.name+"','"+data.text+"');\">Edit</a>");

Problem

I have the following jQuery code: ``` $(".container").append("<a href='javascript:void(0)'onClick='showField('"+data.name+"','"+data.text+"');'>Edit</a>"); ``` Which is outputting (notice the quote problem before the `4` and before the `>edit`: ``` <a href="javascript:void(0)" onclick="showField("4','school_type');'>Edit</a> ``` When it should be outputting: ``` <a href="javascript:void(0)" onclick="showField('4','school_type');">Edit</a> ```

Original source