Recommendations on Triming Large Amounts of Text from a DOM Object

Posted by aronchick on Stack Overflow See other posts from Stack Overflow or by aronchick
Published on 2010-03-29T03:20:21Z Indexed on 2010/03/29 3:23 UTC
Read the original article Hit count: 322

Filed under:
|

I'm doing some in browser editing, and I have some content that's on the order of around 20k characters long in a <pre>.

So it looks something like:

<pre>
Text 1
Text 2

Text 3
Text 4
[...]
Text 20,000
</pre>

I'd like to use jquery to trim it down when someone hits a button to chop, but I'm having trouble doing it without overloading the browser. Assume I know that the character numbers are at 16,510 - 17,888, and what I'd like to do is trim it.

I was using:

jQuery('#textsection').html(jQuery('textarea').html().substr(range.start));

But browsers seem to enjoy crashing when I do this. Alternatives?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery