Is it possible to create a progress bar using data attributes in JQuery? Unfortunately, performing both actions simultaneously seems to be an issue.
<div class="progressbar">
<div class="progressvalue" data-percent="50"></div>
</div>
.progressbar {
background: #9696A0;
height: 20px;
border-radius: 10px;
color: #fff;
text-align: center;
font-size: 14px;
position: relative;
z-index: 3;
}
.progressvalue {
background: #4650C8;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 0;
z-index: -1;
border-radius: 10px;
}
$('.progressvalue').each(function() {
var $this = $(this);
$this.css('width', $this.data('percent') + '%');
$this.parent().text('tournament progress: ' + $this.data('percent') + '%');
});
The current result is as shown above in the code snippet, but ideally it should be different.
Any suggestions on how to achieve the desired outcome?