jQuery滑块UI不滑动

Jac*_*sor 2 jquery jquery-ui

我正在使用jQuery滑块UI作为音频播放器中的滑块,只有滑动功能在我设置变量时才起作用.

$('.body_container .slider').slider({

  value: 0,
  step: 0.01,
  orientation: "horizontal",
  range: "min",
  max: song.duration,
  animate: true,  

  slide: function(event,ui) {             
    manualSeek = true;
  },
  stop:function(event,ui) {
    manualSeek = false;         
    song.currentTime = ui.value;
  }
});
Run Code Online (Sandbox Code Playgroud)

在firebug中它出现了错误closestHandle is undefined.closestHandle来自jQuery UI文件.

但是当我在函数中没有设置任何选项并且只是保留事件时它确实有效,但显然我需要设置选项;

$('.body_container .slider').slider({

  slide: function(event,ui) {             
    manualSeek = true;
  },
  stop:function(event,ui) {
    manualSeek = false;         
    song.currentTime = ui.value;
  }
});
Run Code Online (Sandbox Code Playgroud)

Cyc*_*eak 9

有点晚了,但要确保song.duration是一个数字.您可以使用parseFloat()来确定.