0

txtPhones 数组无法存储值给出空白警报。警报(txt电话);在 removefromlist() 函数中没有给出任何内容当我在“createSpanforuser()”函数中检查“txtPhones”时它给出了完美的值但是“txtPhones”在 removefromlist 中是空白的

    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
    }
4

0 回答 0