2015-11-28 88 views
0

我試圖從這裏使用引導程序滑塊:https://github.com/seiyria/bootstrap-slider。但是我無法初始化滑塊。 我的代碼片段看起來是這樣的:引導程序滑塊未初始化

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <link href="css/bootstrap-switch.min.css" rel="stylesheet"/> 
    <link href="https://raw.githack.com/seiyria/bootstrap-slider/master/css/bootstrap-slider.css" rel="stylesheet" /> 
    <link rel='stylesheet' href='css/jquery-ui.css'> 
    <link rel='stylesheet' href='css/ol.css'> 
    <script src="js/jquery-ui.js"></script> 
    <script src="http://openlayers.org/en/v3.9.0/build/ol.js"></script> 
    <script src="js/jquery.ui.widget.js"></script> 
    <script src="js/jquery.iframe-transport.js"></script> 
    <script src="js/jquery.fileupload.js"></script> 
    <script src="https://raw.githack.com/seiyria/bootstrap-slider/master/js/bootstrap-slider.js"></script>  
    <script src="js/bootstrap-switch.min.js"></script> 

</head> 

<body> 
     <input style='width:80px;' class='opacity' type='text' value='' data-slider-min='0' data-slider-max='1' data-slider-step='0.1' data-slider-tooltip='hide'> 

    <script type="text/javascript"> 
     $('input.opacity').slider(); 
    </script> 

</body> 

這讓我簡單的輸入類型,圖中所示

enter image description here

然後,如果我做的:

$('input.opacity').bootstrapSlider(); 

這給了我錯誤爲:

enter image description here

我在這裏錯過了什麼?

回答

0

請儘量

$(function() { 
    $('input.opacity').bootstrapSlider(); 
}); 

當文件準備好執行代碼。

+0

請參閱[jsFiddle](https://jsfiddle.net/c33jLond/) – Chris