【发布时间】:2013-12-21 22:05:24
【问题描述】:
我用 listjs (listjs.com) 做了一个列表
现在我正在使用函数 get(),这将给我这个返回:
itemsInList = [
{ id: 1, name: "Jonny" }
, { id: 2, name "Gustaf" }
];
listObj.get("id", 2); -> return { id: 2, name: "Gustaf" }
现在我只想使用纯 javascript 获取名称 id。
function getUserName(uid) {
var itemValues = hackerList.get("id", uid)[0];
console.log("The name of the user is: " + itemValues.name);
// or use alert..
//alert("The name of the user is: " + itemValues.name);
}
对不起,不具体...我想从返回值:
{ uid: 2, name: "Marc" ... }
到 itemValues.name -> Marc
Udate
忘记使用 uid 函数(“id”)。当我使用 values() 时,它会起作用。谢谢你的回答。
更新小提琴 Fiddle
【问题讨论】:
-
您需要帮助解决什么问题?
标签: javascript html object listjs