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 [email protected]
How to upload custome file in ckeditor in php
Hello everyone we are sharing a one very...How to get Local Time Instead of Server Time
Suppose you are managing blog website an...Using the $loop variable in foreach loops in Laravel Blade
Laravel provides simple blade template w...How to pass data from PHP to JavaScript
PHP is server side language which retrie...Laravel 8 CRUD Operation with example from the scratch
CRUD operation is a basic functionality...