$(".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>');
我收到了意外的令牌错误,因为在附加li时 我在编写确认对话框时开始使用单引号 面对一个问题我怎么能提到里面的报价&#34;你确定吗?&#34; 这个onclick基本上是一个引号问题=&#34; if(确认(&#34;你是吗?) ?肯定&#34;)) removegroupuser(&#39; + GROUPID +&#39;&#39 + MSG1 [I] [0] + .ID&#39;);&#34;
答案 0 :(得分:0)
将confirm
中的引号更改为单撇号并将其转义:
onclick="if(confirm(\'Are you sure?\')) removegroupuser('+groupid+','+msg1[i][0].id+');"
或使用HTML实体:
onclick="if(confirm("Are you sure?")) removegroupuser('+groupid+','+msg1[i][0].id+');"
答案 1 :(得分:0)
$('.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>');