I have a simple textarea. Is it possible with jquery to add a ‘br’ when I hit the enter button?
I’ve read around here, and the only solution I see is to add a linebreak at the very end of the val().
But I need it to work on every enter press.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can simply split on the line feed:
and then spit each one out as a paragraph:
If you’re just wanting to put the result into a database as you’ve stated, you can do the same but build it into a string for insersion:
Based on your comments it looks like you just need the br added when you insert the data into your database. I’m assuming that you’re doing this with an ajax post since you’ve tagged this as a jQuery question.
Either way, you can just send your data to the server and split it up there using your server side language of choice.