I am facing an issue with nested HTML div elements on my website. The data is being fetched from a JSON file and stored in a variable.
For example, the 'obj' variable contains an array of objects with properties such as Name, Progress, Description, and Status. These can be accessed using the following syntax:
obj[index].Name
obj[index].Progress
obj[index].Description
obj[index].Status
I need to iterate over each div element and populate it with the corresponding data using jQuery.
For instance, I want to loop through each info-box inside the div(#row) and update the values within the specified HTML elements:
- <span class="info-box-text">NAME-1</span>
- <div class="progress-bar" style="width: 70%"></div>
- <span class="progress-description">PRODUCT-DESCRIPTION-1 </span>
- <span class="label label-info">PROGRESS-1</span>
The jQuery each function should iterate through the following HTML structure:
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box">
<div class="info-box bg-yellow">
<span class="info-box-icon"><i class="ion ion-filing"></i></span>
<div class="info-box-content">
<span class="info-box-text">NAME-1</span>
<div class="progress">
<div class="progress-bar" style="width: 70%"></div>
</div>
<span class="progress-description">
PRODUCT-DESCRIPTION-1
</span>
<span class="label label-info">PROGRESS-1</span>
<span style="padding-left:5px" class="ion-person-stalker"> 5</span>
</div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box">
<div class="info-box bg-green">
<span class="info-box-icon"><i class="ion ion-filing"></i></span>
<div class="info-box-content">
<span class="info-box-text">NAME-2</span>
<div class="progress">
<div class="progress-bar" style="width: 85%"></div>
</div>
<span class="progress-description">
PRODUCT-DESCRIPTION-2
</span>
<span class="label label-success">PROGRESS-2</span>
<span style="" class="ion-person-stalker"> 8</span>
</div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box">
<div class="info-box bg-red">
<span class="info-box-icon"><i class="ion ion-filing"></i></span>
<div class="info-box-content">
<span class="info-box-text">NAME-3</span>
<div class="progress">
<div class="progress-bar" style="width: 70%"></div>
</div>
<span class="progress-description">
PRODUCT-DESCRIPTION-3
</span>
<span class="label label-success">PROGRESS-3</span>
<span style="" class="ion-person-stalker"> 15</span>
</div>
<!-- /.info-box-content -->
</div>
</div>
</div>
</div>