我知道这应该很简单,但我想检查进度条是否等于100%。如果有的话,我似乎无法触发警报。
var bar = $('.progress-bar').text(val);
var val = percentage + '%';
var percentage=1;
if(bar == 100){
alert("100");
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="bar">
<div class="progress">
<div class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar" aria-valuenow="10"aria-valuemin="0" aria-valuemax="100" style="width:10%">100%</div>
</div>
</div>
&#13;
答案 0 :(得分:1)
$(document).ready(function(){
var percentage = someFunctionToGetPercentage();
$('.progress-bar').text(percentage + '%');
if (parseInt($('.progress-bar').text()) == 100) { // or $('.progress-bar').text() == '100%'
alert(100);
}
});