ie 7/8不支持trim的属性的解决方案

时间:2016-09-10 13:15:08   收藏:0   阅读:181
if(!(‘trim‘ in String.prototype)){
    String.prototype.trim = function(){
        return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,‘‘);
    }
}

console.log(‘(‘ + ‘ aaa ‘.trim() + ‘)‘);

原文:http://www.cnblogs.com/gongshunkai/p/5859149.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!