我有function delete()
:
var array = new Array();
function deleteMessage(name, role, date, time,text) {
alert(text);
}
var message = array[i].message.replace(/'/g,"\\'");
还有input
<input id='delete' name='delete' type='submit' value='Delete' onclick='deleteMessage(\""+ array[i].name + "\",\""+ array[i].role + "\",\""+ array[i].date + "\",\""+ array[i].time + "\",\""+ message +"\")'>
我的函数最后一个参数text
如何获得一个在其中带有一些单引号的字符串。
我尝试用.replace(/'/g,"\'");
,.replace(/'/g,"\\'");
,.replace(/'/g,"\\
'“)代替;
我尝试替换像这样的字符串"It\'s my life"
什么都没有,有人知道该怎么做?