Code based on jquery loop map function_jquery
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use PUT request method in jQuery?

Optimize the performance of Go language map

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags

What are the alternatives to recursive calls in Java functions?

PHP returns all the values in the array to form an array

Things to note when Golang functions receive map parameters

Understand the role and application scenarios of eq in jQuery
