2

I'm trying the following to add a linebreak in the title attribute.

<p id="test" title="1|2">test</p>


 var lineBreak = $("<div>&#10</div>").html();

 $("#test").attr("title", $("#test").attr("title").replace("|", lineBreak));

The tooltip result in IE9 is

1
2

in IE8 the result is

12

Is there a chance to fix this for IE8? I really need this way and no custom tooltip etc.

Try it @ jsfiddle: http://jsfiddle.net/8ZCdb/

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
Keith L.
  • 2,084
  • 11
  • 41
  • 64

1 Answers1

5

Try this:

$("#test").attr("title", $("#test").attr("title").replace("|", "\n"));

\n is a new line operator in plain text.

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148