作者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