0
我想了解jquery,我有問題需要從數組中追加值。jQuery中的循環槽對象
我已經創建了下面的物體:
var obj = [];
我把它放在槽循環推送數據:
obj.push({
name: name,
address: address,
comment: comment,
distance: distance,
duration: duration,
lat: lat,
lng: lat,
count: count,
order: order
});
我console.log(obj)
:
0: Object
address: "Test"
comment: "My comment"
count: 1
distance: "3.3 mi"
duration: "13 mins"
lat: "44.971424"
lng: "44.971424"
name: "My House"
order: "3.3"
1 : Object
2 : Object
3 : Object
4 : Object
5 : Object
我的問題是:
如何附加到div?
$("#div_result").each(obj, function(){
// ??
// This is not working for me.
});
尋求調試幫助的問題(「**爲什麼不是這個代碼工作?」)必須包含所需的行爲,*特定的問題或錯誤*和*最短的代碼*重現它* *在問題本身**。沒有**明確問題陳述**的問題對其他讀者沒有用處。請參閱:[如何創建最小,完整和可驗證示例](https://stackoverflow.com/help/mcve)。 – Andreas
在每個內部使用$ this進行調試,並嘗試獲得您需要的內容 –