javascriptbootstrap-4bootstrap-slider

Bootstrap Input Slider - very basic setup


I'm trying for a very basic setup for a bootstrap'ish input slider and somehow I cant get it to work.

What I want:

enter image description here

What I get:

enter image description here

Source / Working example / Tutorial:

http://seiyria.com/bootstrap-slider/

My code / source / error:

<html>
<head>

    <link rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.9.0/css/bootstrap-slider.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">


</head>
<body>

<input id="ex1" data-slider-id='ex1Slider' type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1"
       data-slider-value="14"/>


<script type='text/javascript'>
    $('#ex1').slider({
        formatter: function (value) {
            return 'Current value: ' + value;
        }
    });
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.9.0/bootstrap-slider.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</body>
</html>

Note:

I pull all the basic components (CSS/JS): bootstrap, bootstrap-slider and JQuery from the web repositories.


Solution

  • Here I fixed it for you. https://jsfiddle.net/k5k9aa70/

    Your scripts were executing out of order and slider wasn't recognized as a function.