Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用键获取Localstorage的值_Jquery_Debugging - Fatal编程技术网

Jquery 使用键获取Localstorage的值

Jquery 使用键获取Localstorage的值,jquery,debugging,Jquery,Debugging,我已将以下数据保存在localstorage中 { pages: "[{"id":1443515245154,"name":"Bohemia"},{"id":1443515285226,"name":"Brand"}]" } 现在我想得到像whereid=1443515245154或id=1443515285226这样的值。请帮我解释一下 $.each(data, function (index, value) { $.each(value.pages, function (

我已将以下数据保存在localstorage中

{
    pages: "[{"id":1443515245154,"name":"Bohemia"},{"id":1443515285226,"name":"Brand"}]"
}
现在我想得到像where
id=1443515245154
id=1443515285226
这样的值。请帮我解释一下

$.each(data, function (index, value) {

    $.each(value.pages, function (index1, value1) {

        console.log(value1.id)

    })

})

var data = [{
    "pages": [{
        "id": "1443515245154",
            "name": "Bohemia"
    }, {
        "id": "1443515285226",
            "name": "Brand"
    }]
}]

试试这个。我修复了数据,因为它不是正确的json,请检查我使用的数据并将其与您的数据进行比较。 检查json是否有效

更新

var pages = data[0].pages;
console.log(pages[0].id)
console.log(pages[1].id)

您需要在
页面
中解析JSON,然后在生成的数组上循环,并检查每个对象的
id
值,以找到您要查找的对象。这显然是基于这样的假设,即错配的引号是问题中的一个输入错误。我知道如何从每个循环中获取值,但我希望通过id直接获取值,比如php,其中id=11111