Make tooltip read html tag

Asked

Viewed 94 times

2

I am using the jQuery tooltip and need to display a message formatted with html, for example

$(function(){
  $("input:file").tooltip();
});
<link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<input type='file' title="<b>m</b>ensagem <i>formatada</i>">

I wish he understood html

1 answer

3


I think this script would solve

In the jQuery tooltip you can use:

 $(function() {
       var el = $("input:file");
       var msg = el.attr('title');
       el.tooltip({
          content : msg
       });
    });

On the Bootstrap you can use:

 $(function() {
      var el = $("input:file");
      el.tooltip({
          html : true
      });
 });
  • 1

    Your answer is correct for the jquery tooltip, but by a certain coincidence I was using the bootstrap tooltip and didn’t notice.. now that I’ve found a solution, it would be interesting to add your answer $("input:file").tooltip({&#xA; html : true&#xA; });

  • 1

    Melhor rsrs..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.