javascript - Removing white space and blank line from local text file -


showowi  g exsu n  sierouz  nicee99 

this content extracted image screenshot , saved text file called b&w1.txt

i trying remove blank spaces in line append these list using following js code

        var filename="../static/r6scoreex/extract/b&w1.txt"         $.get(filename,function(txt){             var lines = txt.responsetext.split("\n");             len = lines.length;             (var j = 0 ; j < len; j++) {                 //save(lines[i]);                 if((lines[j]!='') && (  lines[j]!='undefined')){                      $('#text'+i).append("<li>"+lines[j]+"</li>");              }          });  

but still empty string getting inserted

change this:

            if((lines[j]!='') && (  lines[j]!='undefined'));                  $('#text'+i).append("<li>"+lines[j]+"</li>"); 

to:

 if((lines[j]!='') && (  lines[j]!='undefined')) {      $('#text'+i).append("<li>"+lines[j]+"</li>"); } 

i.e. put code in body of if statement


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -