1

I want to add data-title attribute for responsive data-table. And td data-title contains break statement tag. But break statement tag is not working. Below is my sample code,

<td data-title='Goods<br>Code'></td>

I want both 'Goods' and 'Code' in two lines.

James Z
  • 12,209
  • 10
  • 24
  • 44
L.Nelson
  • 63
  • 5
  • 14

2 Answers2

3

I think data-* attributes only support string and html code will not effect on it so try to change

<td data-title='Goods<br>Code'></td>

to

<td data-title="Goods\nCode"></td>

\n as new line

EDIT

Try to add data-html="true" I see this answer please check it https://stackoverflow.com/a/13705417/5441049

Or use JQuery tooltip plugin

https://www.w3schools.com/bootstrap/bootstrap_ref_js_tooltip.asp

Mahmoud Gamal
  • 322
  • 4
  • 10
2

This one should work :

#table th, #table td{
    padding:0.8em;
    border: 1px solid;
}
#table th{
    background-color:#6699FF;
    font-weight:bold;
}
<table id="table">
  <tr>
        <th>ID</th>
        <th>Text</th>
       
    </tr>
 <tr>
        <td>1</td>
        <td title="Goods&#010;Code">Hover Me</td>
    </tr>
</table>

Just run the snippet and hover over the "Hover Me" cell and you should see the title just as you desired it to be.

"&#013; is \r and &#010; is \n
On Windows new line is &#013;&#010; on unix &#010;"
node_man
  • 1,359
  • 4
  • 23
  • 50