首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

100分,JS有关问题,待

2012-08-24 
100分,JS问题,在线等待。JScript codevar obj [Object object, Object object, Object object, Object ob

100分,JS问题,在线等待。

JScript code
var obj = [Object object, Object object, Object object, Object object, Object object];// 每一个Object中都有一个Id,name。 我如去匹配何删除id=0,id = 2 ,所在的对象。


[解决办法]
for(i=obj.length-1;i>-1;i--)
{
 if(obj[i].Id=="0" || obj[i].Id=="1")
{
obj.splice(i,1); 
}
}
[解决办法]
JScript code
var obj = [Object object, Object object, Object object, Object object, Object object];var obj2 = [];//放置所有被删除之后剩余的元素var obj3 = [];//放置所有满足删除条件,需要删除的元素for(var i = 0 ; i < obj.length ; i ++){if(obj[i].id != "0" && obj[i].id != "2"){obj2.push(obj[i]);}else{obj3.push(obj[i]);}} 

热点排行