If I have a textarea on an HTML page with multiple lines of text in it, how can I most easily append more text to one of those lines (chosen based on user input) using only Javascript?
Share
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.
By splitting the text on the
\nnewline character you get an array of lines. From there, append to any line and join the array with the new line character you previously took out.Note that this will only work if you insert new lines into the text field. If the text is naturally wrapping, then you will have to do a more complicated character count tactic to divide the lines into your array.