简体   繁体   中英

How To Update JQuery Progress Bar Value from a Variable

I have a Problem Regarding the JQuery Progress Bar.

I Need to set the Value of the Progress bar with the Value stored in a Javascript Variable.

 $(document).ready(function () 
{
    var text = $('.Gadget').find('input[name="Percentage"]').val();


 $(function() 
{
    $( ".ProgressBar" ).progressbar({
    value: 59
});

});

});

The Above code works fine, but as there is Value 59 the value is always Constant.

What I Really need is that instead of the 59, there will be the value of the text Variable.

Note: if I Put Value:text, the Progress bar disappears

Thank You, Andrew Borg

You need to do it in the single document.ready handler. Use parseInt() to make it numeric:

$(document).ready(function () {
    var text = $('.Gadget').find('input[name="Percentage"]').val();

    $( ".ProgressBar" ).progressbar({
       value: parseInt(text)
    });

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM