作者kolocoyima (客倌来看看!)
看板Ajax
标题[问题] prototype.push.apply 新增到阵列问题
时间Sun Dec 21 20:14:25 2014
var arr = new Array ("001","002","003");
var file = document.getElementById('file').files[0];
if (file)
{
i = String(file.name);
arr.prototype.push.apply([i]);
}
利用file button选取档案抓取档名
并且把档名强制转为字串
然後使用push新增到阵列
请问这样写对吗?
for(j=0;j<=arr.length;j++)
{
i = String(file.name);
arr.prototype.push.apply(???);
}
document.write(arr);
}
如果要使用for回圈的话是要这样写吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.231.6.103
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/Ajax/M.1419164069.A.890.html
※ 编辑: kolocoyima (61.231.6.103), 12/21/2014 20:16:49
1F:推 oToToT: 不是只要arr.push就好 12/21 23:43
2F:→ swijo: var arr=[]; ...arr.push(file[0].name); 12/22 02:28
3F:→ swijo: s 12/22 02:28
4F:推 mrbigmouth: 没事不要乱用建构式 会很惨 12/22 08:32