Search

11/20/2009

Preserve line break in textarea

http://chunghe.googlecode.com/svn/trunk/experiment/textarea.preserve.line.break.htm
* set the textarea's value by textarea.value, not textarea.innerHTML
* use br2nl before inserting a<br>b into textarea


var br2nl = function (str) {
return str.replace(/<br\s*\/?>/img, "\r");
}

沒有留言: