简体   繁体   English

修剪在IE7中不起作用

[英]Trim is not working in IE7

trim() javascript function not working in IE7 however it' working fine in all other version and all browser. trim()javascript函数在IE7中不起作用,但它在所有其他版本和所有浏览器中都运行良好。 what should be issue with IE7 or how i can resolve this? 什么应该是IE7的问题或我如何解决这个问题?

$("#Email").val().trim()

IE7给出了错误

Thanks in advance. 提前致谢。

IE doesn't support String.prototype.trim() until IE9. IE直到IE9才支持String.prototype.trim()

It looks like you're using jQuery, so you can use $.trim() instead. 看起来你正在使用jQuery,所以你可以使用$.trim()代替。

$.trim($("#Email").val())

The val() method doesn't always return a string . val()方法并不总是返回一个string If the selected item is an option it can return an array which doesn't support trim . 如果所选项目是一个选项,它可以返回一个不支持trim的数组。 Have you checked the type of val() to see if it's actually a string ? 你检查了val()的类型,看看它是否真的是一个string

Note: As others have pointed out trim isn't supported on IE7 even if this is a string . 注意:正如其他人指出的那样,IE7不支持trim ,即使这是一个string Need at least IE9. 至少需要IE9。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM