document.querySelector('#emails-view').innerHTML=`
<table id="emails-table" class="table table-hover">
<thead class="thead-dark">
<tr>
<th>To</th>
<th>Subject</th>
<th>Text</th>
</tr>
</thead>
<tbody id="table-body">
</tbody>
</table>
`
for(var i=0;i<emails.length;i++){
let row = document.createElement('tr');
let cols = '<td>' + emails[i].recipients + '</td><td>' + emails[i].subject + '</td><td style="width:50%;"> ' + emails[i].body + '</td>';
row.innerHTML = cols;
document.getElementById('table-body').appendChild(row);
}
I'm creating an emails table with JS, and I would like to set a lenght limit to the email text, followed by "...", so that the text stands only in 1 row, and doesnt take 4 rows like in the image.
This is the table :
I tried by modify the <td>
style in this:
<td style="width:50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
but still doesnt works, this is what happen:
How can I fix this? (I would like that the email text is the 50% of tha table width). Thank you!