附加数据时如何写单引号和双引号?

how to write single and double quotes while appending data?

 $(".overlayp ul").append('<li id="group_'+msg1[i][0].id+'" class="list_items"><div class="row"><div class="col-xs-2 col-md-1"><div class="itemAvatar"><img src="'+url+'/service/getUserImage/'+msg1[i][0].id+'/32" alt="avatar"></div></div><div class="col-xs-10 col-md-11"><div class="item"><div class="item-title">'+msg1[i][0].name+'<span class="pull-right members"><a onclick="if(confirm("Are you sure?"))
removegroupuser('+groupid+','+msg1[i][0].id+');">Remove User</a></span></div></div></div></div></li>');

i am getting the unexpected token error because while appending the li i have started with single quote while writing the confirm dialog box facing a problem how could i mention the quote inside "Are you sure?" basically a quotes problem in this onclick="if(confirm("Are you sure?")) removegroupuser('+groupid+','+msg1[i][0].id+');"

confirm 中的引号更改为单引号并转义:

onclick="if(confirm(\'Are you sure?\')) removegroupuser('+groupid+','+msg1[i][0].id+');"

或使用HTML个实体:

onclick="if(confirm(&quot;Are you sure?&quot;)) removegroupuser('+groupid+','+msg1[i][0].id+');"
$('.other_info_container').append('<div id="logg_div_id" style="width: 110%;display:none;" alt="tttt123"><div style="width: 100%;float:right;  margin-left:10px;  "><div id="show_login_info_add_collapse" style="float:left;width:98%;padding: 10px"><div style="margin-top: 8px"><div class="confirm_box_login" style="display:none; width:51%; padding:10px;     margin-left: 155px; border:1px solid black; background:#99CCFF;"><font id="ms1"  size="2"> There are <b id="cntr_lgn"></b><b id="cntr2"></b>changes found,Do you want to update changes ?</font><br/><div class="login_dtls" style="width:90%; margin:auto; padding:5px;"></div><div class="confirm_btn_lgn" style="width:90%; margin:auto; text-align:center; padding:5px;"><input type="button" id="confirm_insert_lgn" value="Yes" style="width:100px; border:1px solid black; background:#0099FF; cursor:pointer; padding:5px;" /><input type="button" id="cancel_delete_lgn" value="No" style="width:100px; border:1px solid black; background:#0099FF; cursor:pointer; padding:5px;"/></div></div><span style="cursor:pointer;margin-left: 5px;font-weight: bold;font-size: 15px;" onclick="">Login Details <label style="    color: red;margin-left: 1px;font-size: 11px;" id="dalert_login"></label></span><div style="float:left;margin-top: -8px"></div><div style="float:right;margin-right:78%;margin-top: -8px"></div><label id="edit_alert_login" style="color: red;font-size: 11px;margin-left: 3px;font-weight: 500;"></label></div></div><form id="passform" style="float:left;" onClick="globalsave(\'logg_div_id\');detect_add_activity(\'logg_div_id\');" ><input type="hidden"  name="empid" value="'+new_idemp+'"/></div></div>');