不能让noUISlider工作

时间:2015-07-24 00:42:20

标签: javascript jquery slider nouislider

我无法让noUISlider工作 这是我的代码片段:

<script>
var handlesSlider = document.getElementById('slidertest');

noUiSlider.create(handlesSlider, {
	start: [ 4000, 8000 ],
	range: {
		'min': [  2000 ],
		'max': [ 10000 ]
	}
});
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST</title>    
<link rel="stylesheet/less" type="text/css" href="css/style.less"/>
<link href="css/nouislider.min.css" rel="stylesheet">
<script src="scripts/less.js"> </script>
<script src="scripts/jquery-2.1.4.min.js"> </script>
<script src="scripts/jquery-ui.min.js"> </script>
<script src="scripts/dropzone.js"> </script>
<script src="scripts/nouislider.min.js"> </script>
</head>



...

<div id="slidertest"></div>

我收到此错误: 未捕获的TypeError:无法读取null的属性'nodeName'

1 个答案:

答案 0 :(得分:4)

尝试使用以下内容包围您的javascript:

$( document ).ready(function() {
    var handlesSlider = document.getElementById('slidertest');

noUiSlider.create(handlesSlider, {
    start: [ 4000, 8000 ],
    range: {
        'min': [  2000 ],
        'max': [ 10000 ]
    }
});
});