html - Perl code to check progress bar level and display through jQuery -
I have a Perl code that gets the percentage of usage which is 30% I have written HTML, which That's the value in class Progress Bar and Pearl as $ usage. And I've used that category to show the progress bar in a page in jQuery. But this is not working
& lt; Link rel = "stylesheet" href = "// code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"> & Lt; Script src = "// code.jquery.com/jquery-1.10.2.js"></script> & Lt; Script src = "// code.jquery.com/ui/1.11.2/jquery-ui.js"></script> & Lt; Script & gt; $ (Function () {$ ("#progressbar"). Programbar ("value");}); & Lt; / Script & gt; & Lt; Div class = "progress bar" value = & lt;% $ usage_percentage% & gt; & Lt; / Div & gt; & Lt;% Perl & gt; My $ usage_percentage = 30; & Lt; /% Pearl & gt;
Please help in advance thanks.
Some things are wrong in your code. First, you use the ID selector $ ("# progressbar")
, but your HTML does not have any such id Change
& lt; Div class = "progressbar" ... & gt;
to
& lt; Div id = "progressbar" ... & gt; Second, value
& lt; Div & gt;
is not a valid feature for the tag, when the data from HTML to HTML / JavaScript is passing from Perl, then I recommend using it, for example
and lt; Div id = "progressbar" data-percent-used = "30" & gt; & Lt; / Div & gt;
provides one to access the jQuery data - *
attributes:
Var percent usage = $ ("#progressbar"). Data ("percent-usage"); // 30
Note that you can use the data-*
attributes in HTML4, they are only considered as regular attributes.
Third, you are calling a method for the progress bar, do not set it
to
$ (" #progressbar ") .progressbar (" value "); $ ("#progressbar") .progressbar ({value: 30});
& Lt; Script & gt; $ (Function () {var container = $ ("#progressbar"); container.progressbar ({value: container.data ("percent-usage"}}}}); & lt; / script & gt; & lt; Div id = "progressbar" data-percent-used = "& lt;% $ usage_percentage%>" & gt; & lt; / div & gt;
Comments
Post a Comment