Getting value from object in javascript

痞子三分冷 提交于 2019-12-19 05:06:39

问题


After console.log(item) I got following object.

Object {_value: "106", _id: "opt_zXtP8TOfW2zteOgDIJQDI6Bxx3xSTkl5", _class: "selected", _selected: "selected"}

I want _value from this object. How can I do this?

I tried alert(item.value) but gets undefined


回答1:


You're ignoring the underscore. value and _value are not the same. You need to use:

item["_value"];

Or:

item._value;


来源:https://stackoverflow.com/questions/21305400/getting-value-from-object-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!