如何通过使用jQuery循环遍历json对象

时间:2018-05-30 17:05:59

标签: javascript jquery json

我正在尝试循环遍历JSON对象,但我不起作用,我希望它看起来像结构化。请帮助!!

如何通过使用jquery来遍历这个?把它放在一个结构中?

[
    {   "name": "Webredpizzan", 
        "price": 20, 
        "content":["Ost","Gorgonzola","Mozarella"], 
        "picture":"images/item3.jpg"
    },


    {
        "name": "IT-pizzan", 
        "price": 10, 
        "content":["Ost","Lamm","Kalkon"], 
        "picture":"images/item1.jpg"
    },
    {
        "name": "Bibliotekspizzan", 
        "price": 11, 
        "content":["Ost","Basilika","Mozarella"], 
        "picture":"images/item2.jpg"
    },
    {
        "name": "Frukt-pizzan", 
        "price": 20, 
        "content":["Banan","Blåbär","Äpple"], 
        "picture":"images/item3.jpg"
    }
]

我想把它放在这个结构中

<div class="pizza_details">
<img src="'+picture+'" />

<div class="desc">'
<ul> <li><span>Namn</span> : '+ name +'</li>
<li><span>Pris</span> : '+price;+'</li>
<li><span>Innehåll</span> : '+content+'</li>
</ul></div><div class="clear"></div> </div>

0 个答案:

没有答案