0

I have a text area that a user can type in then with a button it gets displayed. When they add spaces I get in error in the JavaScript though because its all not on the same line. Is there a way to display the new lines with a JavaScript button press?

$(button).click(function(){
    $(DisplayUserTextArea).html('<p> <%= @user.TextArea %> </p>');
});

This what happens when it runs on the site and its getting an error here because its spaced out.

Uncaught SyntaxError: missing ) after argument list

$(button).html('<p> Test Text </p>


<p>TESTTTTTTT</p>');
0

1 Answer 1

2

Use backtick (`) symbol instead of '
For example:

$(button).html(`<p> Test Text </p>


<p>TESTTTTTTT</p>`);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.