so I'm doing a code that basically removes empty lines, as well as remove empty spaces in the beginning of the string and at the end. However `trim` function seems that it doesn't work how can i fix that?

that's the code that i have tried

```
<textarea id="a">
 a

 b
 c   
</textarea><button id="c">Remove blank lines</button><textarea id="b"></textarea>

```

And the jQuery code is:

```
jQuery(function ($) {
    $("#c").on("click", function () {
        var avalue = $.trim($('#a').val());
        var newVal = avalue.replace(/^\s*[\r\n]/gm, '');
        $('#a').val(newVal);

    });
})

```