Latest web development tutorials

jQuery UI exemplo - barra de progresso (Progressbar)

Exibir um certo processo ou estado de incerteza.

Para mais detalhes sobre o sócio progressbar, consulte a documentação da API membro barra de progresso (Progressbar o Widget) .

A função padrão

O padrão é determinado barra de progresso.

<! DOCTYPE html>
<Html lang = "PT">
<Head>
  <Charset Meta = "utf-8">
  <Title> jQuery UI barra de progresso (Progressbar) - A função padrão </ title>
  <Link rel = "stylesheet" href = "// code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <Script src = "// code.jquery.com/jquery-1.9.1.js"> </ script>
  <Script src = "// code.jquery.com/ui/1.10.4/jquery-ui.js"> </ script>
  <Link rel = "stylesheet" href = "http://jqueryui.com/resources/demos/style.css">
  <Script>
  $ (Function () {
    $ ( "#progressbar") .progressbar ({
      valor: 37
    });
  });
  </ Script>
</ Head>
<Body>
 
<Div id = "progressbar"> </ div>
 
 
</ Body>
</ Html>

etiqueta personalizada

etiqueta de actualização personalizado.

<! DOCTYPE html>
<Html lang = "PT">
<Head>
  <Charset Meta = "utf-8">
  <Title> jQuery UI barra de progresso (Progressbar) - Tab personalizado </ title>
  <Link rel = "stylesheet" href = "// code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <Script src = "// code.jquery.com/jquery-1.9.1.js"> </ script>
  <Script src = "// code.jquery.com/ui/1.10.4/jquery-ui.js"> </ script>
  <Link rel = "stylesheet" href = "http://jqueryui.com/resources/demos/style.css">
  <Style>
  .ui-progressbar {
    position: relative;
  }
  .progress-label {
    position: absolute;
    left: 50%;
    top: 4px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #fff;
  }
  </ Style>
  <Script>
  $ (Function () {
    var progressbar = $ ( "#progressbar"),
      progressLabel = $ ( ".progress-label");
 
    progressbar.progressbar ({
      Valor: false,
      alterar: function () {
        progressLabel.text (progressbar.progressbar ( "value") + "%");
      },
      completar: function () {
        progressLabel.text ( "Complete!");
      }
    });
 
    progresso function () {
      var val = progressbar.progressbar ( "value") || 0;
 
      progressbar.progressbar ( "value", val + 1);
 
      Se (val <99) {
        setTimeout (progresso, 100);
      }
    }
 
    setTimeout (progresso, 3000);
  });
  </ Script>
</ Head>
<Body>
 
<Div id = "progressbar"> <div class = "progresso-label"> Carregando ... </ div> </ div>
 
 
</ Body>
</ Html>

valor indeterminado

Indeterminado barra de progresso, e pode alternar entre certo e incerto estilo.

<! DOCTYPE html>
<Html lang = "PT">
<Head>
  <Charset Meta = "utf-8">
  <Title> jQuery UI barra de progresso (Progressbar) - valor indeterminado </ title>
  <Link rel = "stylesheet" href = "// code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <Script src = "// code.jquery.com/jquery-1.9.1.js"> </ script>
  <Script src = "// code.jquery.com/ui/1.10.4/jquery-ui.js"> </ script>
  <Link rel = "stylesheet" href = "http://jqueryui.com/resources/demos/style.css">
  <Script>
  $ (Function () {
    $ ( "#progressbar") .progressbar ({
      Valor: false
    });
    $ ( "Button") .em ( "click", function (event) {
      -alvo var = $ (event.target),
        progressbar = $ ( "#progressbar"),
        progressbarValue = progressbar.find ( "-progressbar valor .ui");
 
      Se (target.is ( "#numButton")) {
        progressbar.progressbar ( "opção", {
          valor: Math.floor (Math.random () * 100)
        });
      } Else if (target.is ( "#colorButton")) {
        progressbarValue.css ({
          "Background": '#' + Math.floor (Math.random () * 16777215) .toString (16)
        });
      } Else if (target.is ( "#falseButton")) {
        progressbar.progressbar ( "opção", "valor", false);
      }
    });
  });
  </ Script>
  <Style>
  #progressbar .ui-progressbar valor {
    background-color: #ccc;
  }
  </ Style>
</ Head>
<Body>
 
<Div id = "progressbar"> </ div>
<Button id = "numButton"> valor aleatório - OK </ button>
<Button id = "falseButton"> Claro </ button>
<Button id = "colorButton"> cores aleatórias </ button>
 
 
</ Body>
</ Html>