jquery数组,并以自定义格式显示



我有一个类似的对象:

{
a:{'1':'Blue','2':'Red'},
b:{'1':'Large','2':'Small'}
}

我希望使用jQuery显示我的数组,如下所示:

蓝色/大

蓝色/小型

红色/大

红色/小型

通过两个循环可以实现这一点,

let obj = {
a:{'1':'Blue','2':'Red'},
b:{'1':'Large','2':'Small'}
}
const result = document.getElementById("result")
for(let i in obj['a'])
for(let j in obj['b'])
result.innerHTML += `<h4>${obj['a'][i]} - ${obj['b'][j]}</h4>`
<div id="result"></div>

我的对象有动态行和列:

{
1:{1:'Blue',2:'Red',3:'Green'},
2:{1:'S',2:'M',3:'L',4:'XL'},
3:{1:'Guarantee One',2:'Guarantee Two'},
}

因此,结果将是动态的:

蓝色/S/保证一

蓝色/S/保证二

蓝色/M/保证一

蓝色/M/保证二

蓝色/L/保证一

蓝色/L/保证二

蓝色/XL/保证一

蓝色/XL/保证二

红色/S/保证一

红色/S/保证二

红色/。。。

最新更新