heldplayer Posted October 20, 2009 Report Share Posted October 20, 2009 is there a way to insert linebreaks in a textarea with just HTML and javascript? Link to comment Share on other sites More sharing options...
jeffman Posted October 20, 2009 Report Share Posted October 20, 2009 Use the "\n" character.In a textarea, "hello\nworld" renders as:helloworldTip: this is also true of alert messages. Link to comment Share on other sites More sharing options...
heldplayer Posted October 20, 2009 Author Report Share Posted October 20, 2009 it doesn't do anything exept if you write <textarea>hello \n world</textarea> it gives hello \n world else it displays hello world if you script it, nothello world Link to comment Share on other sites More sharing options...
justsomeguy Posted October 20, 2009 Report Share Posted October 20, 2009 You use \n as an escape sequence in Javascript to create a newline. If you're just typing text into a text area, if you want a linebreak you use the enter key. Link to comment Share on other sites More sharing options...
heldplayer Posted October 20, 2009 Author Report Share Posted October 20, 2009 did you tested it?it doesn't work for me, but I've been thinking, can't you use the entity name of enter to insert it, like < and >what is the entity name of enter cause i can't find it in the reference Link to comment Share on other sites More sharing options...
justsomeguy Posted October 20, 2009 Report Share Posted October 20, 2009 There's not an entity for a linebreak. I haven't tested, sorry. See if a regular <br> shows up as a line break in a textarea or if it shows <br>. Link to comment Share on other sites More sharing options...
heldplayer Posted October 20, 2009 Author Report Share Posted October 20, 2009 (edited) <br> breaks my code<br> just shows <br>edit: ff displays \n as it should be, ie does not Edited October 20, 2009 by Mitchel Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now