$.trim space 使用 $.trim 在 Jquery 中不起作用

$.trim space using $.trim doesn't work in Jquery

        $(".p").each(function(i){
          len=$(this).text().length;
          if(len>80)
          {
            $(this).text($(this).text().substr(0,80)+'...');
          }
        });  

我的一些输出很好,比如

abc def...

但有些会像

1234 45 ...

如何trim space?我尝试了 $.trim 但没有用。

这应该有效:

$(".p").text(function() {
    var text = $(this).text();
    if (text.length > 80) {
        return $.trim(text.substr(0, 80)) + '...';
    } else {
        return text;
    }
});