我有问题使用 jquery获取对象数组中的所有元素… 我从互联网上获取此代码… var id = 123;var test = new Object();test.Identification = id;test.Group = "users";test.Persons = new Array();test.Persons.push({"FirstNam
我从互联网上获取此代码…
var id = 123; var test = new Object(); test.Identification = id; test.Group = "users"; test.Persons = new Array(); test.Persons.push({"FirstName":" AA ","LastName":"LA"}); test.Persons.push({"FirstName":" BB ","LastName":"LBB"}); test.Persons.push({"FirstName":" CC","LastName":"LC"}); test.Persons.push({"FirstName":" DD","LastName":"LD"});
如何使用JQuery获取人员中的“FirstName”和“LastName”?
你可以使用$.each()或$.map(),具体取决于你想用它做什么.$.map(Persons, function(person) { return person.LastName + ", " + person.FirstName; }); // -> ["Doe, John", "Appleseed, Marc", …]