突然在我的网站上,可点击的按钮使滑块变为不同的值因为此错误而停止工作:未捕获的TypeError:$(...)。slider不是函数
主滑块代码有效,并且没有弹出错误,说滑块不是这个函数:`
$( "#test" ).slider({
range: "max",
min: minCoins,
max: 100000,
value: 2,
step: 10000,
slide: function( event, ui ) {
var slidVal = ui.value;
if ( slidVal%10000 == 0 ){ // this condition because for each slide we are increasing the value by 1000
slidValCm = slidVal;
$("#noofCoins").html(numberWithCommas(slidValCm));
document.getElementById('coinsBought').value = ($('#noofCoins').text());
$('#quantity').val(); //just empty input for security purpose
}
for ( i = 0;i <= slidVal;i++ )
{
if ( i%10000 == 0 && i != 0){
quant = quant+1;
exactCoint = exactCoint+10000;
costCoin = costCoin+costPair;
costCoinFi = (costCoin*1).toFixed(2);
$("#quant").html(quant);
$('#quantity').val(parseInt(quant));
$("#price-preview").html("<span class='money'>£"+costCoinFi+"</span>");
Currency.convertAll(defaultCurrency, Currency.currentCurrency);
}
if ( i == 0){
$("#quant").html(0);
$("#price-preview").html("<span class='money'>£"+costCoinFi+"</span>");
Currency.convertAll(defaultCurrency, Currency.currentCurrency);
}
}
costCoin = 0;
quant = 0;
}
});`
但是,对于单独的快速值按钮,它不会更新滑块位置,因为它表示滑块不是一个功能。例如,这是其中一个按钮的事件处理程序之一。
$("#20k").on('click', function(){
var coinNum = 20000;
var totlCost = getCost(coinNum);
var totquan = (coinNum/rngCoins/10);
$("#quant").html(totquan);
$('#quantity').val(parseInt(totquan));
$("#price-preview").html("<span class='money'>£"+totlCost+"</span>");
$("#noofCoins").html("20,000");
$("#test").slider('value', 20000);
document.getElementById('coinsBought').value = ($('#noofCoins').text());
Currency.convertAll(defaultCurrency, Currency.currentCurrency);
});
这 - $("#test").slider('value', 20000);
- 将是问题的问题。为什么是这样?感谢