Add line break within tooltips

后端 未结 27 2305
北恋
北恋 2020-11-28 02:23

How can line breaks be added within a HTML tooltip?

I tried using
and \\n within the tooltip as follows:



        
相关标签:
27条回答
  • 2020-11-28 02:59

    <br /> did work if you are using qTip

    0 讨论(0)
  • 2020-11-28 02:59

    For me, a 2-step solution (combination of formatting the title and adding the style) worked, as follows:

    1) Format the title attrbiute:

    <a ref="#" title="First Line
                      Second Line
                      Third line">Hover Me</a>
    

    2) Add this style to the tips element:

    white-space: pre-line;
    

    Tested in IE8, Firefox 22, and Safari 5.1.7.

    0 讨论(0)
  • 2020-11-28 02:59

    Just add this code snippet in your script:

        $(function () {
            $('[data-toggle="tooltip"]').tooltip()
        });
    

    and ofcourse as mentioned in above answers the data-html should be "true". This will allow you to use html tags and formatting inside the value of title attribute.

    0 讨论(0)
提交回复
热议问题