Multiple HTML lines with jquery tooltip plugin

Posted by dafi on Stack Overflow See other posts from Stack Overflow or by dafi
Published on 2010-03-22T07:54:30Z Indexed on 2010/03/22 10:51 UTC
Read the original article Hit count: 391

Filed under:
|
|

I'm using the plugin http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ to create tooltips with JQuery but I can't created tooltips containing 3 (or more) lines of HTML code.

I need to render as tooltip the content shown below (obviously the content is generated dynamically an this it only a proof of concept)

<p>Line1</p>
<p>Line2 <span style="...">blah blah</span></p>
<p>Line3</p>

The showBody property seems applicable only to title attributes.

Found the problem

Apparently jquery.html("...") requires a root tag otherwise generates an empty string.

My original code was

bodyHandler: function() {
  return $("<span id='caption'>line1</span>"
         + "<span id='tags'>line2</span>");
}

need to be written with a dummy root tag removed by JQuery

bodyHandler: function() {
  return $(
        "<root-dummy-tag>"
        + "<span id='caption'>line1</span>"
        + "<span id='tags'>line2</span>"
        + "</root-dummy-tag>"       
      );
}

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-plugins