我有一个名为“additions_colorizing_items
”的数组。它内部有对象,如下所示:
var additions_colorizing_items = [
'',
{
"name": 'viking_helmet',
"actual_name": 'Viking Helmet',
"rows": 4,
"first_color": '#ED2C2B',
"started_color": 4,
"type": 'H',
"type_in_words": 'head',
"have_shadow_now": 'always',
'need_shadow': false
},
{
"name": 'hard_hat',
"actual_name": 'Hard Hat',
"rows": 4,
"first_color": 1,
"started_color": '#F6EB56',
"type": 'H',
"type_in_words": '',
"have_shadow_now": 'always',
'need_shadow': false
}, ....]
问题是$.inArray
函数在这种情况下不起作用:
this_id = 'viking_helmet';
alert(additions_colorizing_items[$.inArray(this_id, additions_colorizing_items.name)].actual_name);
目标是:将name
转换为数组内同一对象的actual_name
,例如:viking_helmet
- > Viking Helmet