0

Need Help for.
I have one texarea which i have write keyword then press Enter key result with <BR> generate.

$("#chat_box").keydown(function (e){
    if(e.keyCode == 13){                            
    var textval = $("#chat_box").val();
    alert(textval+' you pressed enter ^_^');
    }
    });


    ENTER : Hello,
           test

   OUTPUT: Hello, test (That not correct)

Enter Key works perfectly.
I have also try it Append()
Suggestion me.

Thank you

Edited by ravi142: add some code

2
Contributors
1
Reply
15
Views
3 Years
Discussion Span
Last Post by diafol
1

The textarea is probably storing '\n' (newline) not '<br />'.

You could try...

textval = textval.replace(/(\n)+/g, '<br />');
Votes + Comments
Thank you.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.