What is the best way to trim() in javascript

前端 未结 19 1952
眼角桃花
眼角桃花 2020-11-29 06:32

The question says it all; JS doesn\'t seem to have a native trim() method.

19条回答
  •  鱼传尺愫
    2020-11-29 07:02

    The answer to so many JavaScript questions: jQuery

    $j.trim(string)
    



    Note: the above assumes your jQuery has been setup with:

    
    

    Which is far more sensible than "$", and far less verbose than typing "jQuery" every time.

提交回复
热议问题