I know you wanted a javascript solution, but in case someone found this page a solution but for emails (where Javascript isn t an option), I decided to post my solution.
Use CSS white-space: nowrap
. So what I do is surround the last two or three words (or wherever I want the "break" to be) in a span, add an inline CSS (remember, I deal with email, make a class as needed):
<td>
I don t <span style="white-space: nowrap;">want orphaned words.</span>
</td>
In a fluid/responsive layout, if you do it right, the last few words will break to a second line until there is room for those words to appear on one line.
阅读更多关于<条码>white-space的这一链接财产:。 http://www.w3schools.com/cssref/pr_text_white-space.asp
EDIT:12/19/2015——由于在《展望》中得到了支持,I ve正在增加一个没有突破的空间<代码>和>;nbsp;。 最后一句中最后两字之间。 它的代码较少,在任何地方都得到支持。
EDIT: 2/20/2018 - I ve发现,《展望》(iOS和Andrew)并不支持
entities,因此我必须结合两种解决办法: e.g:
<td>
I don t <span style="white-space:nowrap;">want orphaned words.</span>
</td>