Display only whole word using javascript
<p>I have a text say "A sample text for testing". I need to display only ten characters in a div.
so i do substring on the text </p>

<pre><code>txt.substring(0,10) 
</code></pre>

<p>This gives me "A sample t". Since its ugly to display a unterminated word, i need only to display "A Sample" to be displayed. How do i do this?</p>
