How to Remove Blank Lines Using Javascript?

Remove Blank Lines by JavaScript, Remove the Blank Lines in a Textarea With JavaScript, Remove Line Breaks Using a Javascript Language, Remove all Blank Lines Using Regular Expressions


Friends, what happens when we are programming in any language. So sometimes there is rows or blank space in our programming, whether it is programming of html or programming of php language. By the way, these problems are more so when we are extracting our zip file and uploading it to cpanel’s server. Occur.

Hello Guys so i will tell you today through expertsphp tutorial how you can remove the blank space of your programming language through javascript.

I will try to understand you through Javascript Programming Language, so let’s go.

First of all, you create a textarea type in html and add id space to it.
Then after that you will have to write script type in Javascript Language, I would like to tell you that raplace is a function of Javascript with the help of which you can remove the blank line, let’s see how we can do this.



<title>How to Remove Blank Lines Using Javascript?</title>
<textarea id="space">


</textarea><button id="remove">Remove blank lines</button>

<script src=""></script>
jQuery(function ($) {
$("#remove").on("click", function () {
var avalue = $('#space').val();
var newVal = avalue.replace(/^\s*[\r\n]/gm, '');
//var finalResults = newVal.replace("\n", "");