我有一个jquery滑块功能和其他javascript函数 我想在javascript中检索jquery滑块的值,但我不能 如果我这样做
var s=$( "#slider_placement" ).slider( "value" );
在javascript中说错误
Error: cannot call methods on slider prior to initialization; attempted to call method 'value'
我尝试在java脚本中执行此操作
var h = $('#custom-handle').text();
console.log(h);
但控制台显示空结果
这里是jquery滑块代码
$( function() {
var handle = $( "#custom-handle_wins" );
$( "#slider_wins" ).slider({
min:1,
max:10,
value:1,
step:1,
create: function() {
handle.text( $( this ).slider( "value" ) );
},
slide: function( event, ui ) {
handle.text( ui.value );
var s=ui.value;
document.getElementById("no_wins").innerHTML='Number of Wins: ' + ui.value;
}
});
s=$( "#slider_wins" ).slider( "value" );
document.getElementById("no_wins").innerHTML='Number of Wins: ' + s;
} );