{
"id":["123"],
"optionid_123":"98"
}
I have the id
as a variable, but from that how can I get the optionid_*
? I tried a few things, but nothing seems to work. The each
is inside of the appropriate function and jsonid contains the correct value. Here is my attempt at accessing the value 98
which doesn't work:
$.each(data.id,function(){
var jsonid = this;
console.log( data.optionid_+jsonid ); // doesn't work
});
You can use Bracket notation:
console.log( data['optionid_' + jsonid] );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With