0
我喜歡有一個數組包含10個不同的食譜,在每個頁面上加載我想用這些食譜填充一個div,我是新的數組,但我不知道爲什麼沒有在此提醒?從數組中挑選隨機項並填充 - jQuery
var recipes = [{
"image": "image1.jpg",
"ingredients": {
"a": "eggs",
"b": "chips"
},
"link" : "google.com"
}, {
"image": "image2.jpg",
"ingredients": {
"a": "chocolate",
"b": "cheese"
},
"link" : "msn.com"
}];
var recipe = recipes[0];
alert(recipe);
http://jsfiddle.net/6otvzr1p/1/
我得到'[對象的對象]'是'alert'的正常輸出當被要求顯示一個JS對象時。 – Alnitak 2014-10-10 09:37:53
這在這裏工作 – devqon 2014-10-10 09:37:54
'食譜[0] .image'是你想在你的HREF? – 2014-10-10 09:38:44