Keith L.
Keith L.

Reputation: 2124

javascript/jQuery: Adding linebreak in title -- works in IE9, but not in IE8

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/

Upvotes: 2

Views: 532

Answers (1)

Mathew Thompson
Mathew Thompson

Reputation: 56429

Try this:

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

\n is a new line operator in plain text.

Upvotes: 5

Related Questions