作者tyf99 (呵呵)
看板Ajax
标题Re: [问题] setAttribute一串参数
时间Thu Sep 22 19:00:19 2011
Array.map(func()) 好像不能直接处理有传回值的函数,只有第一个会收到
需要自己写一个 map function
var allInt=function(obj)
{
if(typeof(obj)=="object")
for(var i in obj)
obj[i]=allInt(obj[i]);
else
return parseInt(obj);
return obj;
}
var test=new Array("1a",null,"3a","xx","5a");
document.write( test + "<br/>");
document.write( allInt(test) + "<br/>");
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.211.197.209
1F:→ robinnpca:感谢!我又学到一个map的用法!虽然还不太熟 09/22 21:02