我在Rails应用程序中使用工具提示,但由于我的代码在输入字段上不起作用,因此:

  %input#main-search{:name => "query", :placeholder => "search all
    items", :rel => "tooltip", :title => "Search All Items", :type => "text"}
  :javascript
    $(document).ready(function(){
      $('input[title]').tooltip({placement:'bottom'});
    });

我还使用:
$('#main-search').tooltip({'trigger':'focus'});

它不适用于输入字段,但适用于标签。如何禁用输入字段的工具提示?

最佳答案

这是工具提示的有效HTML标记:

<input data-toggle="tooltip" title="tooltip on second input!" type="text" placeholder="Focus me!" name="secondname"/>

这是jQuery,具有正确的工具提示位置并触发了焦点:
$('input[type=text][name=secondname]').tooltip({ /*or use any other selector, class, ID*/
    placement: "right",
    trigger: "focus"
});

Always look at official docs

这是工作演示:http://jsfiddle.net/N9vN8/69/

关于twitter-bootstrap - Bootstrap Tooltip在输入字段上不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16079884/

10-11 22:04
查看更多