mardi 11 octobre 2016

Display line breaks in text area using jQuery

I have a form with select tag and a text area. Content of the text area is dynamically displayed based on the select tag value.

At the same time user can change the text area value and saved it.

When page loads the text area value is displayed via jQuery from a hidden field value.

The problem I am having is with line breaks.

I do following when I display the text area value

var original_content = $('#original_customer_text').val().replace(/\r/g,"\r").replace(/\n/g,"\n");

but results is displayed like this

line 1 goes here
              line 2 goes here
              line 3 goes here

how do I remove the spacing in second and third line when displaying value in text area ?

Aucun commentaire:

Enregistrer un commentaire