function createslider(){
document.getElementById("loadSlider").innerHTML='<input id="ex1" data-slider-id="ex1Slider" type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="14"/>';
}
// Without JQuery
var slider = new Slider('#ex1', {
formatter: function(value) {
return 'Current value: ' + value;
}
});
#ex1Slider .slider-selection {
background: #BABABA;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.9.0/css/bootstrap-slider.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.9.0/bootstrap-slider.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.9.0/bootstrap-slider.js"></script>
<button onclick="createslider()"> Click me</button>
<div id="loadSlider">
<!--
<input id="ex1" data-slider-id='ex1Slider' type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="14"/>-->
</div>
问题:单击事件 javascript 上不显示引导滑块
说明: 如果我取消隐藏滑块 HTML 代码(没有 onlclick 事件)它工作正常但是当我加载基于 onlclick 按钮滑块不显示时,只显示输入框