If you are using the textarea in your application and users input some paragraph in the textarea and application store this input in a database and you fetch this info and display on a web page then you many time face the input data not display like a paragraph. but if you are working on PHP then you can easily be doing with nl3br() through, but if you are using in jquery or javascript then you have to first declare that. I did give a full example of jquery Textarea line breaks asunder.
<body>
<textarea class="textareac"></textarea>
<script>
var text_content = <?php echo $content ?>;
function nl2br (str, is_xhtml) {
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br/>' : '<br>';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}
$(".textareac").val(nl2br(text_content));
</script>
<body/>
i hope you like this solution.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on harsukh21@gmail.com
How to count all elements or values in an array in PHP
Use the PHP count() or si...Laravel 5.6 - RealTime CRUD System Using Google Firebase
Today, we are share with you how to buil...How to get all the keys of an associative array in PHP
Use the PHP array_keys() funct...How to run Python 3 Script in Laravel 7?
Hi, Artisan In this article i will sh...How to forEach Over an Array in JavaScript
Use the forEach() Method You ca...