Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery tooltip add line break

So, I want to take the content of a div in which I have several <br/>, and then pass it as a title attribute using jQuery tooltip widget. I want the lines to appear one beneath the other inside the tooltip. thx. the code so far is:

CSS

.Lines {     width: 125px;     height:20px;     overflow:auto; } 

JavaScript

$(function () {     $(document).tooltip();      $(".Lines").hover(function () {         IaTxt = $(this).html()          $(this).prop('title', IaTxt)      }) }); 

HTML

<div class="Lines">     First line.     <br/>Second line.     <br/>Third line!     <br/>Fourth line? </div> 
like image 216
ChrisGP Avatar asked Jan 30 '13 08:01

ChrisGP


People also ask

How do I add a line break in tooltip?

Just use the entity code &#013; for a linebreak in a title attribute.

How do you insert a line break in title attribute?

You can use &#013; or &#010; .


1 Answers

There's a pure CSS solution. Use \n for newlines, and add this CSS style:

.ui-tooltip {     white-space: pre-line; } 

You can also use pre or pre-wrap instead of pre-line, if you want to preserve whitespace. See https://developer.mozilla.org/en-US/docs/Web/CSS/white-space

like image 200
zooglash Avatar answered Sep 25 '22 07:09

zooglash