javascript - 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 sure?")) removegroupuser('+groupid+','+msg1[i][0].id+');">remove user</a></span></div></div></div></div></li>');
i getting unexpected token error because while appending li have started single quote while writing confirm dialog box facing problem how mention quote inside "are sure?" quotes problem in onclick="if(confirm("are sure?")) removegroupuser('+groupid+','+msg1[i][0].id+');"
change quotes in confirm
single apostrophes , escape them:
onclick="if(confirm(\'are sure?\')) removegroupuser('+groupid+','+msg1[i][0].id+');"
or use html entities:
onclick="if(confirm("are sure?")) removegroupuser('+groupid+','+msg1[i][0].id+');"
Comments
Post a Comment