Jquery 操作Json数组获取key和Value - reckcn

时间:2024-03-04 15:52:45
 //var data = { "ms": [{ "Gender": "0", "Birthday": "0", "IDNumber": "0", "NationString": "0", "HuJiString": "0", "EthnicString": "0", "StartingToWork": "0", "CurrentCityString": "0", "Political": "0", "JoinDTime": "0", "IsMarriage": "0", "MarriageTime": "0", "IsFertility": "0", "FertilityTime": "0", "Religion": "0", "GoToWorkType": "0", "GoToWorkTime": "0", "PositionString": "0", "IndustryString": "0", "LocationString": "0", "NatureOfWork": "0", "MinSalary": "0", "MaxSalary": "0", "Welfare": "0", "OtherRequest": "0", "CoverLetter": "0", "Height": "0", "Weight": "0", "Health": "0", "Vision": "0", "Liquor": "0", "Dysfunction": "0", "IllnessHistory": "0", "DrugAllergies": "0", "OtherTaboos": "0" }] };
            var json = str.ms;
            for (var i = 0; i < json.length; i++) {
                for (var key in json[i]) {
                    //console.log("key:" + key + ",value:" + json[i][key]);
                    if (json[i][key] == 0) {
                        $("#" + key).attr("checked", true);
                    }
                }
            }