txtPhones数组无法存储值给出blanck警报。 警报(txtPhones); removefromlist()函数中没有任何内容 我在“createSpanforuser()”函数中检查“txtPhones”,它给出了完美的价值 但“删除列表”中的“txtPhones”为空白
var txtPhones=[];
function createSpanforuser(id, uname) {
txtPhones=uname.split(",");
document.getElementById("tdTeliphone").innerHTML="";
alert(txtPhones); //gives correct value
for(var lp=0;lp<txtPhones.length;lp++){
var myID=lp+"span4"+id;
document.getElementById("tdTeliphone").innerHTML+="<span id="+myID+"> " +txtPhones[lp]+"<span id=Inner"+myID+" class=hyper onclick='removefromlist(\"" + myID + "\",\"" + txtPhones[lp] + "\")'> <img class=imgspan src=../img/cross-script.png style=width:14px;height:14px /> </span> </span> </br>";
}
}
function removefromlist(idSpan, uname) {
$('#' + idSpan).remove();
alert(txtPhones); //gives blank
}