I have a table with some long texts and some short texts. If a <td>
contains a long text I would like to increase the width.
This is what I tried to do:
var text = $('td').text().split('\n');
if(text.length === 1) {
$(this).css('width','270px');
}
jsFiddle
I tried to get the number of line breaks with alert(text.length)
and i get 1. Then if there is 1 line break I added .css('width','270px')
, but doesn't work. What I did wrong?
Thanks for help!