Without further ado, look at the code
var map = {
Place names: ["Beijing", "Tianjin", "Shanghai"],
Ethnicity: ["Han", "Tibetan", "Uyghur"]
};
$.each (map,function(key,values){
console.log(key);
$(values).each(function(){
console.log("t" this);
});
});
If firebug is installed, the console will output the following tree structure:
Place name
Beijing
Tianjin
Shanghai
Ethnicity
Han Chinese
Tibetan
Uyghur
Note: The difference between $().each and $.each in jquery is that the former can only traverse arrays, while the latter can traverse Arrays and objects
Note: The place name ontology in the sinobook project is classified by type. The background package is a map (key is a relationship type, and the value is a list). The frontend can output it in the above way.