How to break line in jQueryUI tooltip

后端 未结 4 978
半阙折子戏
半阙折子戏 2021-02-05 03:35

The new version of jQueryUI (1.9) comes with the native tooltip widget. After testing with it, it works fine if the content (value of the title attribute) is short. But if the c

4条回答
  •  忘了有多久
    2021-02-05 04:01

    I have a solution for jQuery 2.1.1, similar to @Taru's solution.

    Basically, we have to use tooltip's content call to dynamically get the data from the element. The element itself can have any html markup in it. Note that you need to import

    So, onload, I do this:

    $(function() {
        $( document ).tooltip({
          content:function(){
            return this.getAttribute("title");
          }
        });
      });
    

    And my example element is this:

    hover me

提交回复
热议问题