Split the string based on
tag using jquery

前端 未结 10 850
温柔的废话
温柔的废话 2021-01-17 20:04

How can i split the string containing
tag using jquery. I tried the following code but it get error in console. I am not sure how to split the strin

10条回答
  •  感情败类
    2021-01-17 20:37

    Can't you just do something like:

     var lines = 'this is for testing 
    How are you
    '.split('
    ');

    Just as a side note if you want to get rid of the empty elements you can filter the lines like so:

    // this will get rid of empty elements 
    lines = lines.filter(function(n) { 
        return n; 
    });
    

提交回复
热议问题