Jquery implementation of a simple progress bar effect example

  • 2020-03-30 02:55:11
  • OfStack

Jquery implements the effect of a progress bar, which may not have any practical effect here, but it has implemented part of the principle of a progress bar, and how the front end implements that progress effect.

Effect demonstration:

< img SRC = "border = 0 / / files.jb51.net/file_images/article/201405/201451290213769.jpg? 20144129230 ">

Progress bar source code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery Implementation progress bar </title>
 .progressBar{width:200px;height:8px;border:1px solid #98AFB7;border-radius:5px;margin-top:10px;}
<script type="text/jscript" src="jquery.min.js"></script>
<script type="text/javascript">
 function progressBar(){
  //Initialize the js progress bar
  //The smaller the progress bar, the faster
  var speed = 20;

  bar = setInterval(function(){
   nowWidth = parseInt($("#bar").width());
   //The width must not be greater than the total width of the progress bar
    barWidth = (nowWidth + 1)+"px";
    //When the progress bar is full, stop
 <input type="button" value=" start " onclick="progressBar()" />
 <div class="progressBar"><div id="bar"></div></div>


Related articles: