How can I add each day's players [day-1, day-2, day-3, day-3]
wrapped in a <span>
into the .card-body
section as required? The goal is to load only four card-body
.
var vehicles = {
"day-1": {
"player-1-1": "Ford",
"player-1-2": "BMW"
},
"day-2": {
"player-2-1": "Benz",
"player-2-2": "KIA",
},
"day-3": {
"player-3-1": "Toyota",
"player-3-2": "Mazda",
},
"day-4": {
"player-4-1": "Honda",
"player-4-2": "Nissan",
},
}
Object.getOwnPropertyNames(vehicles).forEach((val, index) => {
var txt = Object.values(vehicles[val]);
console.log(txt);
})
span {
background: orange;
color: #fff;
display: inline-block;
float: left;
padding: 12px;
margin: 5px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="card-body"></div>
<div class="card-body"></div>
<div class="card-body"></div>
<div class="card-body"></div>
<div class="card-body"></div>
<div class="card-body"></div>
<div class="card-body"></div>
<div class="card-body"></div>