Before us, we introduced to youJavaScriptmethods to implementprogress barand implement the progress bar natively. So how to control the progress bar? The elements used by JS to control the progress bar are relatively simple. Just embed a span tag within a p tag. The outer layer of p is used as the background, and the inner layer of span is used for dynamic progress display, which is controlled by JS.
The overall code is as follows:
In order to facilitate display, I wrote thecss textand js script directly in thehtml document, This is a native js way to control the progress bar. It can also be written using js libraries such as Node.js or mootools.
SetProgressOne() uses pictures to display progress; SetProgressTwo() uses color to display progress. The principle is the same, and they all control the attributes of the span tag through JS: style="width :Default value %" is enough. In terms of performance, using images is better than using colors, because it is difficult to use colors to handle rounded corners. Not all browsers support the rounded corner properties of CSS. Here is a comparison of the effects:
Summary:
Through the detailed study of this article, I believe that my friends have a better understanding of JavaScript control progress bar. I hope it will help you Work helps!
Related recommendations:
The above is the detailed content of Example analysis of JavaScript controlling progress bar. For more information, please follow other related articles on the PHP Chinese website!