Javascript Jquery进度条ui进度条

Javascript Jquery进度条ui进度条,javascript,jquery,progress-bar,Javascript,Jquery,Progress Bar,我遇到了一个错误,我想不出如何修复它。此代码用于进度条 TypeError:$(…)。animateProgress不是函数行 我不确定是否要删除第6行的.fn,但我尝试了一下,结果什么也没发生 (function( $ ){ // Simple wrapper around jQuery animate to simplify animating progress from your app // Inputs: Progress as a percent, Callback // TODO

我遇到了一个错误,我想不出如何修复它。此代码用于进度条

TypeError:$(…)。animateProgress不是函数行

我不确定是否要删除第6行的
.fn
,但我尝试了一下,结果什么也没发生

 (function( $ ){
// Simple wrapper around jQuery animate to simplify animating progress from your app
// Inputs: Progress as a percent, Callback
// TODO: Add options and jQuery UI support.

$.fn.animateProgress = function(progress, callback) {    
return this.each(function() {
  $(this).animate({
    width: progress+'%'
  }, {
    duration: 2000, 

    // swing or linear
    easing: 'swing',

    // this gets called every step of the animation, and updates the label
    step: function( progress ){
      var labelEl = $('.ui-label', this),
          valueEl = $('.value', labelEl);

      if (Math.ceil(progress) < 20 && $('.ui-label', this).is(":visible")) {
        labelEl.hide();
      }else{
        if (labelEl.is(":hidden")) {
          labelEl.fadeIn();
        };
      }

      if (Math.ceil(progress) == 100) {
        labelEl.text('Done');
        setTimeout(function() {
          labelEl.fadeOut();
        }, 1000);
      }else{
        valueEl.text(Math.ceil(progress) + '%');
      }
    },
    complete: function(scope, i, elem) {
      if (callback) {
        callback.call(this, i, elem );
      };
    }
  });
  });
};
 })( jQuery );

$(function() {
// Hide the label at start
$('#progress_bar_itm .ui-progress .ui-label').hide();
// Set initial value
$('#progress_bar_itm .ui-progress').css('width', '7%');

// Simulate some progress
$('#progress_bar_itm .ui-progress').animateProgress(43, function() {
$(this).animateProgress(79, function() {
  setTimeout(function() {
    $('#progress_bar_itm .ui-progress').animateProgress(100, function() {
      $('#main_content').slideDown();
      $('#fork_me').fadeIn();
      });
    }, 100);
  });
});

});
(函数($){
//jQuery animate的简单包装,简化应用程序的动画制作过程
//输入:进度百分比,回调
//TODO:添加选项和jQuery UI支持。
$.fn.animateProgress=函数(进度,回调){
返回此值。每个(函数(){
$(此)。设置动画({
宽度:进度+“%”
}, {
期限:2000年,
//摇摆还是直线
放松:"摇摆",,
//这将在动画的每一步调用,并更新标签
步骤:功能(进度){
var labelEl=$('.ui label',this),
valuel=$('.value',标签);
if(Math.ceil(progress)<20&&$('.ui-label',this).is(“:visible”)){
标签隐藏();
}否则{
如果(标签为(“:隐藏”)){
labelEl.fadeIn();
};
}
如果(数学单元(进度)==100){
标签文本(“完成”);
setTimeout(函数(){
标签淡出();
}, 1000);
}否则{
valuel.text(Math.ceil(progress)+'%');
}
},
完成:功能(范围、i、要素){
如果(回调){
callback.调用(this,i,elem);
};
}
});
});
};
})(jQuery);
$(函数(){
//在开始时隐藏标签
$('#progress_bar_itm.ui progress.ui label').hide();
//设定初始值
$('progress#u bar_itm.ui progress').css('width','7%”);
//模拟一些进展
$(“#进度_bar_itm.ui进度”).animateProgress(43,函数(){
$(this).animateProgress(79,function(){
setTimeout(函数(){
$(“#进度_bar_itm.ui进度”).animateProgress(100,函数(){
$(“#主要内容”).slideDown();
$('fork#me').fadeIn();
});
}, 100);
});
});
});

你的
jQuery
$
是一回事吗??对不起,我不知道你指的是哪一位(jQuery);对您在
$
对象的闭包中注册了一个函数,它实际上是
jQuery
。然后您尝试在闭包之外访问该函数,但它似乎根本没有注册。