【发布时间】:2015-07-10 12:20:04
【问题描述】:
我正在尝试从主对象中获取对象。主对象中的数组持有
这些其他对象,我可以通过调用'oData.events.event[0]'来访问第一个元素,但我想循环获取[1], [2], [3]等等。
//this works
var collection = oData.events.event[0];
$("<li>description: " + collection.description + "</li>").appendTo("#shower");
//this does not work :(
var collection = oData.events.event[0];
var output = "<ul>";
for (var i = 0; i < collection.length; i++)
{
output += "<li>" + collection.description + "</li>";
$(output).appendTo("#shower");
collection = collection + 1 //shift to next array
}
output += "</ul>";
【问题讨论】:
标签: javascript jquery arrays sorting stack