var obj =[ { "name":"龙哥", "url":"www.baidu.com" }, { "name":"龙哥2", "url":"www.baidu.com" }, { "name":"中国北京", "url":"www.baidu.com" }, { "name":"della", "url":"www.baidu.com" } ] var txt = "de" for(var i = 0 ; i < obj.length ; i++){ if(obj[i]["name"].indexOf(txt) > -1){ console.log(i); } }
时间: 2024-10-09 07:17:22