how do I strip white space when grabbing text with jQuery?

前端 未结 4 915
庸人自扰
庸人自扰 2020-11-27 10:16

I\'m wanting to use jQuery to wrap a mailto: anchor around an email address, but it\'s also grabbing the whitepace that the CMS is generating.

Here\'s the HTML I hav

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 11:06

    Javascript has built in trim:

    str.trim()
    

    It doesn't work in IE8. If you have to support older browsers, use Tuxmentat's or Paul's answer.

提交回复
热议问题