Q:

Quotes in my HTML?

Sample JSON:
{[
  {
    "modelYear": 2015,
    "divisionId": 7,
    "divisionName": "Cadillac",
    "subdivisionId": 8290,
    "subdivisionName": "Cadillac Cars",
    "modelId": 27204,
    "modelName": "ATS Coupe",
    "lastModifiedDate": "2015-05-01T01:00:00-06:00",
    "effectiveDate": "2014-04-14T01:00:00-06:00"
  },
  {
    "modelYear": 2015,
    "divisionId": 7,
    "divisionName": "Cadillac",
    "subdivisionId": 8290,
    "subdivisionName": "Cadillac Cars",
    "modelId": 27314,
    "modelName": "ATS Sedan",
    "lastModifiedDate": "2015-05-01T01:00:00-06:00",
    "effectiveDate": "2014-04-14T01:00:00-06:00"
  },
  {
    "modelYear": 2015,
    "divisionId": 7,
    "divisionName": "Cadillac",
    "subdivisionId": 8290,
    "subdivisionName": "Cadillac Cars",
    "modelId": 27158,
    "modelName": "CTS Sedan",
    "lastModifiedDate": "2015-05-04T01:00:00-06:00",
    "effectiveDate": "2014-01-01T01:00:00-07:00"
  }
]}

jQuery:
    $.getJSON(
    "/Home/PopulateDivisionDropDown" + "?availOption=" + $("#FoR").text() + "&ModelYear=" + $("#Years").text() + "&divisionID=" + id, {},
    function (myData) {
        $.each(myData, function (i, item) {
            $("#divisionDropDown").append("<li onclick=modelClick('" + item.modelName + "','" + item.subdivisionId + "')><a href='#'>" + item.modelName + "</a></li>");
        });

    });

When I look at the results of the append values if a divisionName has 2 words in it, the resulting HTML looks like this:
<li onclick="divClick('ATS" Sedan','27314')="">

What do I need to do to prevent this behavior?

A:

Note, "Sample JSON" not appear to match "jQuery"
To remove quotation marks from onclick attribute , try
$("#divisionDropDown")
.append(
  $("<li />", {
    "html": $("<a />", {"href":"#", "html":item.modelName}),
    // I had to break up the quotes around the items:
    // "onclick": "modelClick('"+item.modelName+"', '" + item.subdivisionId + "')" 
    "onclick":"modelClick('"+item.modelName+"', '" + item.subdivisionId + "')"
  // return `element.outerHTML` `String`
  })[0].outerHTML
);

