我需要按值获取密钥名称。
Json对象:
{
None : 0,
Public : 82001,
Unclassified : 82002,
Restricted : 82003,
Confidential : 82004,
Secret : 82005,
TopSecret : 82006,
Private : 82007
}
example : I have value 82004 , I want to get key name (Confidential);
答案 0 :(得分:1)
var data = {
None: 0,
Public: 82001,
Unclassified: 82002,
Restricted: 82003,
Confidential: 82004,
Secret: 82005,
TopSecret: 82006,
Private: 82007
}
$.each(data, function (inx, val) {
if (val === 82004) {
console.log(inx)
}
})
试试这个