Search code examples
twitter-bootstraptooltip

Bootstrap Tooltip not working on input field


I,m using tooltip in my Rails app but it not working on input field as my code is:

  %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'});
    });

I also use:

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

Its not work for input field but for label it works fine. how can I inable tooltip for input field?


Solution

  • Here is valid HTML markup for tooltip:

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

    And here is jQuery with right placement for tooltip and trigger on focus:

    $('input[type=text][name=secondname]').tooltip({ /*or use any other selector, class, ID*/
        placement: "right",
        trigger: "focus"
    });
    

    Always look at official docs.

    And here is working demo: http://jsfiddle.net/N9vN8/69/