jQuery looping .each() JSON key/value not working

后端 未结 2 793
情话喂你
情话喂你 2020-12-13 06:21

I am having problems in looping the key/value of JSON by jQuery .each() function

Initially I have a JSON like this:

json = {\"aaa\":[
              {         


        
2条回答
  •  心在旅途
    2020-12-13 06:57

    Since you have an object, not a jQuery wrapper, you need to use a different variant of $.each()

    $.each(json, function (key, data) {
        console.log(key)
        $.each(data, function (index, data) {
            console.log('index', data)
        })
    })
    

    Demo: Fiddle

提交回复
热议问题