jQueryUI tooltip with html content in title attribute

3.6k views Asked by At

Hi I have this problem Jquery UI tooltip does not support html content, I've tried every solutions but no one works out to me. In fact I tried with this code and didn't work either

<script>
    $(document).ready(function () {
        $('li.thumbnail a').tooltip({
            content: function () {
                return 'hola';
            }
        });
    })
</script>

What could I do?

1

There are 1 answers

0
Viktor On

No problem to put html in tooltips. Just be careful with html's special characters (replace them with html entities or alternate double " and single ' quotes) And if you want to make it dynamic, use .attr() instead of jQuery UI methods. I.e:

use:

$('selector').attr('title', 'content here' );

instead of:

$('selector').tooltip({content: 'content here'});

You'll find working examples in this fiddle.