在Bootstrap中向tooltip inner添加描述

时间:2017-09-02 15:42:16

标签: javascript html twitter-bootstrap

我有以下代码,我想在工具提示中为数字添加说明。为什么这段代码不起作用?

HTML

<input id="contract-length"
       class="slider slider-step-2 slider-contract-length"
       data-slider-id="slider-contract-length"
       type="text"
       data-slider-min="1"
       data-slider-max="36"
       data-slider-step="1"
       data-slider-value="1"
       data-slider-tooltip="always"/>

的Javascript

var slider = new Slider('#contract-length', {
  formatter: function(value) {
    return value + 'msc';
  }
});

1 个答案:

答案 0 :(得分:0)

demo page:您需要创建一个类似于:

的boostrap网格
<div class="container-fluid">
<div class='well row'>
    <h3>Example 1:</h3>
</div>
<div class='well row'>
    <input id="contract-length" class="slider slider-step-2 slider-contract-length"
           data-slider-id="slider-contract-length"
           type="text" data-slider-min="1" data-slider-max="36" data-slider-step="1" data-slider-value="1"
           data-slider-tooltip="always"/>
</div>

&#13;
&#13;
var slider = new Slider('#contract-length', {
    formatter: function (value) {
        return value + ' msc';
    }
});
&#13;
.slider {
    width: 100% !important;
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.8.1/css/bootstrap-slider.min.css">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.8.1/bootstrap-slider.min.js"></script>

<div class="container-fluid">
    <div class='well row'>
        <h3>Example 1:</h3>
    </div>
    <div class='well row'>
        <input id="contract-length" class="slider slider-step-2 slider-contract-length"
               data-slider-id="slider-contract-length"
               type="text" data-slider-min="1" data-slider-max="36" data-slider-step="1" data-slider-value="1"
               data-slider-tooltip="always"/>
    </div>
</div>
&#13;
&#13;
&#13;