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

javascript - Bootstrap add tooltip to dropdown - Stack Overflow

programmeradmin2浏览0评论

I am trying to add tooltip to Bootstrap, tried all solutions found on internet - nothing helps. Here is my dropdown(I am also using String and jstl tags):

    <div class="btn-group" style="margin-bottom:5px; width: 100%;">
              <a id="tableNameButton" data-placement="bottom" title="Text" class="my-tooltip my-dropdown tableNameButton btn btn-default btn-block btn-select" data-toggle="dropdown" href="#">Select table <span class="caret"></span></a>
              <form:input class="form-control" id="tableNameFormId" path="tableName" style="visibility: hidden; display: none;" />
              <ul id="tableName" class="dropdown-menu scrollable-menu">
                     <c:forEach items="${databaseTables}" var="databaseTable">
                             <li><a href="#">${databaseTable}</a></li>
                     </c:forEach>
              </ul>
    </div>

And on javascript:

$('.my-dropdown').dropdown();
$('.my-dropdown').tooltip();

This thing doesn't work. Hope someone already solved this problem, thanks in advance.

I am trying to add tooltip to Bootstrap, tried all solutions found on internet - nothing helps. Here is my dropdown(I am also using String and jstl tags):

    <div class="btn-group" style="margin-bottom:5px; width: 100%;">
              <a id="tableNameButton" data-placement="bottom" title="Text" class="my-tooltip my-dropdown tableNameButton btn btn-default btn-block btn-select" data-toggle="dropdown" href="#">Select table <span class="caret"></span></a>
              <form:input class="form-control" id="tableNameFormId" path="tableName" style="visibility: hidden; display: none;" />
              <ul id="tableName" class="dropdown-menu scrollable-menu">
                     <c:forEach items="${databaseTables}" var="databaseTable">
                             <li><a href="#">${databaseTable}</a></li>
                     </c:forEach>
              </ul>
    </div>

And on javascript:

$('.my-dropdown').dropdown();
$('.my-dropdown').tooltip();

This thing doesn't work. Hope someone already solved this problem, thanks in advance.

Share Improve this question asked Oct 17, 2014 at 10:49 PBAPBA 4152 gold badges9 silver badges25 bronze badges 1
  • Did you attach jQuery, DOM ready? – dfsq Commented Oct 17, 2014 at 10:57
Add a ment  | 

2 Answers 2

Reset to default 5

Check you have linked everything up correctly and included the bootstrap.js file. I have set up a JSFIDDLE with your code and the tooltip works:

http://jsfiddle/shannabarnard/ueoxmm9v/

<div class="btn-group" style="margin-bottom:5px; width: 100%;">
    <a id="tableNameButton" data-placement="bottom" title="Text" class="my-tooltip my-dropdown tableNameButton btn btn-default btn-block btn-select" data-toggle="dropdown" href="#">Select table <span class="caret"></span></a>

    <form:input class="form-control" id="tableNameFormId" path="tableName" style="visibility: hidden; display: none;" />
    <ul id="tableName" class="dropdown-menu scrollable-menu">
             <c:forEach items="${databaseTables}" var="databaseTable">
                  <li><a href="#">${databaseTable}</a></li>
             </c:forEach>
    </ul>
</div>

JS

$('.my-dropdown').dropdown();
$('.my-tooltip').tooltip();

I suppose it doesn't work because you didn't add data-attributes like data-toggle and data-placement. Try to add them and I think it'll work.

See fiddle with working example: http://jsfiddle/h56xw8wq/1/

You should have smth like

<li class="dropdown" id="example" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom" > ... </li>

Hope it'll help you:)

发布评论

评论列表(0)

  1. 暂无评论