How can I change the color of a Bootstrap progress bar without losing the text? I have seen this answer:
$('#pb').css({
'background-image': 'none',
'background-color': 'red'
});
It works, but I lose any text in the progress bar.
Using Bootstrap 3.2.0, you can do something like the following:
$(function() {
$("#one").addClass("progress-bar-purple");
$("#two").addClass("progress-bar-orange");
});
.progress-bar-purple {
background-color: purple !important;
}
.progress-bar-orange {
background-color: orange !important;
}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<br/>
<div class="progress">
<div id="one" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
60%
</div>
</div>
<div class="progress">
<div id="two" class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%;">
80%
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With