Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting value from object in javascript

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

like image 706
Kiren S Avatar asked Jun 12 '26 13:06

Kiren S


1 Answers

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

item["_value"];

Or:

item._value;
like image 149
James Donnelly Avatar answered Jun 14 '26 01:06

James Donnelly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!