Porgress酒吧重定向100%

时间:2017-05-04 17:28:17

标签: javascript twitter-bootstrap

我有一个用JS和bootstrap构建的进度条,代码如下:

var totalCountries = 10;
var currentCountries = 0;
var $progressbar = $("#progressbar");

$("#next, #next1").on("click", function(){
  if (currentCountries >= totalCountries){ return; }
  currentCountries++;
  $progressbar.css("width", Math.round(100 * currentCountries / totalCountries) + "%");
});

在每个按钮上按下栏增长,我希望当进度条达到100%时重定向到任一页面。知道怎么做吗?

1 个答案:

答案 0 :(得分:0)

当您的currentCountries等于totalCountries时,您可以进行重定向。

$("#next, #next1").on("click", function(){
  currentCountries++;
  $progressbar.css("width", Math.round(100 * currentCountries / totalCountries) + "%");

  if (currentCountries >= totalCountries){ 
    window.location = "http://www.yoururl.com";
  }
});