admin管理员组文章数量:1417404
trim()
is not working in Internet Explorer
(it's working properly in Chrome
and Firefox
). However I need to trim the value to prevent empty spaces.
trim()
is not working in Internet Explorer
(it's working properly in Chrome
and Firefox
). However I need to trim the value to prevent empty spaces.
3 Answers
Reset to default 3I don't think JavaScript provides trim() does it? Some browsers may implement it, and various libraries implement it.
You can add your own, something like this:
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
If this turns out to be an IE bug, you can always implement your own workaround using RegEx in JavaScript like this left trim function sample - the sample can be expanded to trim both left and right sides. This Regex should work in all browsers.
Have a look @ this -> Trim not working in IE
本文标签: 39trim()39 javascript function issues with Internet ExplorerStack Overflow
版权声明:本文标题:'trim()' javascript function issues with Internet Explorer - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745261651a2650382.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论