score:3
Accepted answer
Try this:
if(oInput.get(0).tagName == "TEXTAREA") {
oInput.val(function(index, value) {
return value.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
}
}
Similar question
- JQuery change new line to line break in TEXTAREA
- textarea line break jquery
- Jquery textarea val() doesnt take new line
- New Line in Textarea to be converted to <br/>
- jQuery tooltip add line break
score:0
Change the assignment to oInput.val(temp);
i.e.
if(oInput.get(0).tagName == "TEXTAREA")
{
temp = oInput.val();
temp = temp.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
oInput.val(temp);
}
score:4
you can try
temp.replace(/\n/g,'<br/>');
second thing is, change oInput.val(temp);
fiddle : http://jsfiddle.net/yXhUV/
Reference: stackoverflow.com
POPULA POST
- Limit number of lines in textarea and Display line count using jQuery
- How to change the number of rows in the textarea using jQuery
- Remove line break from textarea
- jquery text(), interpret<br> as new line
- How do you add line break to JQuery popover
- Update text on textarea value change w/ jQuery
- JQuery tooltip that supports new line
- Add new line character to textarea instead of submitting form
- Jquery or javascript to add one line break <br /> after x amount of characters in a <div>
- jQuery each line in textarea
- Replacing commas in resultset with new line in jQuery
- jQuery - convert <br> and <br /> and <p /> and such to new line
- Break string after specific word and put remains on new line (Regex)
- jquery remove new line then wrap textnodes with block element
- Clone table rows and change IDs of new rows in jQuery
- remove new line when sending request to server via Ajax Post with JQuery
- how to change an input element to textarea using jquery
- Avoid line break when using jquery append() or html()
- jQuery append text in but in a new line
- jQuery new line \n
- jQuery textarea value doesn't convert line breaks
- Jquery append text data with a line break
- Textarea Limit characters per line Jquery or Javascript
- Trigger change event on textarea in jquery
- How can I add a new line to jquery flot ticks
- Jquery Dialog, Adding a new line of styled text
- How can i change hashtag color on textarea by jquery
- jQuery change input type=text to textarea
- Create jQuery cookie, store css body color value, change page, retrieve cookie and apply body color value to new page
- Convert HTML-encoded < br/ > to html new line tag in jquery .text()
- Keep line breaks with jQuery .text() in textarea
- Change text inside textarea jQuery
- What will the jQuery syntax for new line inside php?
- How to detect new row in textarea while typing without setting Line height using JQuery?
- jquery output text in htmlentities except line break
- Change hidden field Value with jquery and get the new value in server
- Store the line break from textarea , store to database and show on frontend?
- jQuery UI shake effect starts on new line
- Change textarea rows in jquery
- jQuery clone with a simple line break
- how to add line break in HTML using jQuery
- Jquery new line after press enter
- How to control new line position after CSS display inline-block break
- jQuery html() and new line characters
- How to dynamically add a new line in a textarea; javascript or jquery
Featured post from same tag
- jQuery: draggable connect to sortable. draggable item has a different DOM from sortable list
- A selector switch id with jquery as condition
- Jquery photo comparison
- jQuery callback after Gravity Form submit
- JSZip Read Zip File and Execute from an Existing Zip File
- JavaScript/JQuery: $(window).resize how to fire AFTER the resize is completed?
- javascript wizard/assistant plugin
- Replacing / Manipulating element in html string using jquery
- jQuery selector question. Select all nodes that do NOT START with (string)
- Bootstrap 3 Carousel won't work. (Yes, I have jQuery loaded before Bootstrap)
- Toggle between boolean attributes JQuery
- jquery ajax with asp.net not working
- Having problems with jqPlot bar chart
- Bootstrap Multiselect Limit Issue
- How to convert string to XML object in JavaScript?