检查JQuery中的进度条是否等于金额

时间:2015-10-02 14:45:56

标签: jquery

我知道这应该很简单,但我想检查进度条是否等于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;
&#13;
&#13;

1 个答案:

答案 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);
    }
});

Fiddle