Adding a newline automatically to a div
Posted: Tue May 04, 2010 10:51 am
I have created an editable div box by using the following code.
<DIV id="textdiv" onClick="this.contentEditable='true';">
<PRE>this is the content</PRE>
</DIV>
and the following is the css for it
#textdiv {
position:absolute;
top:30px;
width:600px;
height:670px;
overflow:auto;
background:#DCDCDE;
}
Now when i start entering data into the div, I want it to automatically go to the newline when the data has reached the width size. Now if i keep on entering some characters, the data just keeps on getting added to the right and adds a scroll bar to the div.
Thanks!
Saj
<DIV id="textdiv" onClick="this.contentEditable='true';">
<PRE>this is the content</PRE>
</DIV>
and the following is the css for it
#textdiv {
position:absolute;
top:30px;
width:600px;
height:670px;
overflow:auto;
background:#DCDCDE;
}
Now when i start entering data into the div, I want it to automatically go to the newline when the data has reached the width size. Now if i keep on entering some characters, the data just keeps on getting added to the right and adds a scroll bar to the div.
Thanks!
Saj