I am trying to append an HTML div with multiple parameters in the onclick function. Even though I am using escape quotes, the HTML is not rendered properly.
This is my HTML:
$("#city-list").append("<div class='user-panel' id='" + user.id + 'onclick=\'openChat(\'' + user.id + '\',\'' + user.username + '\',\'' + user.sex + "\'\")><b>" + user.username + ", " + "(" + user.sex + ", " + user.age + ")</div>");
This is what is rendered:
<div class="user-panel" id="A61o-ko0zVVJaxTbAAAHonclick=" openchat('a61o-ko0zvvjaxtbaaah','adamlee','male'")=""><b>adamlee, (male, 17)</b></div>
$("#city-list").append("<div class='user-panel' id='" + user.id + "onclick='openChat('" + user.id + "','" + user.username + "','" + user.sex + "')><b>" + user.username + ", " + "(" + user.sex + ", " + user.age + ")</div>");