最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bootstrap tooltip on radio input - Stack Overflow

programmeradmin1浏览0评论

This code does not work. Also tried without JS, by putting attributes into <input>. Nothing seems to work.

$('#radio1').tooltip({
    placement: "bottom",
    trigger: "hover"
});
<link rel="stylesheet" href=".3.6/css/bootstrap.min.css">

<div class="btn-group" data-toggle="buttons">

    <label class="btn btn-primary active">
        <input type="radio" name="options" id="radio1" autoplete="off" 
            data-toggle="tooltip" title="tooltip on radio!">Radio 1
    </label>

    <label class="btn btn-primary">
        <input type="radio" name="options" id="radio2" autoplete="off">Radio 2
    </label>

</div>

<script src=".11.3/jquery.min.js"></script>
<script src=".3.6/js/bootstrap.min.js"></script>

This code does not work. Also tried without JS, by putting attributes into <input>. Nothing seems to work.

$('#radio1').tooltip({
    placement: "bottom",
    trigger: "hover"
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn./bootstrap/3.3.6/css/bootstrap.min.css">

<div class="btn-group" data-toggle="buttons">

    <label class="btn btn-primary active">
        <input type="radio" name="options" id="radio1" autoplete="off" 
            data-toggle="tooltip" title="tooltip on radio!">Radio 1
    </label>

    <label class="btn btn-primary">
        <input type="radio" name="options" id="radio2" autoplete="off">Radio 2
    </label>

</div>

<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.6/js/bootstrap.min.js"></script>

Share Improve this question edited Jul 7, 2016 at 19:51 Gleb Kemarsky 10.4k7 gold badges46 silver badges71 bronze badges asked Jul 7, 2016 at 18:33 ProgZiProgZi 1,2674 gold badges17 silver badges30 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Try to apply tooltip's attributes to the <label>:

$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn./bootstrap/3.3.6/css/bootstrap.min.css">

<div class="btn-group" data-toggle="buttons">

  <label class="btn btn-primary active" data-toggle="tooltip" data-placement="bottom" title="tooltip on radio!">
    <input type="radio" name="options" id="radio1" autoplete="off">Radio 1
  </label>

  <label class="btn btn-primary">
    <input type="radio" name="options" id="radio2" autoplete="off">Radio 2
  </label>

</div>

<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.6/js/bootstrap.min.js"></script>

发布评论

评论列表(0)

  1. 暂无评论