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

Member Avatar

diafol

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

You could try...

textval = textval.replace(/(\n)+/g, '<br />');
commented: Thank you. +0