I am making use of trim() like so:

if($('#group_field').val().trim()!=''){

Where group_field is an input element of type text. This works in Firefox but when I try it on IE8 it gives me this error:

Message: Object doesn't support this property or method

When I remove the trim(), it works fine on IE8. I thought the way I am using trim() is correct?

感谢所有人的帮助

推荐答案

Try this instead:

if($.trim($('#group_field').val()) != ''){

More Info:

Jquery相关问答推荐

使用 howler.js 中的变量播放多种声音

如何限制select2中的字符?

jQuery在页面加载 timeshift 动到锚点位置

jQuery 上传进度和 AJAX 文件上传

动态加载 css 样式表在 IE 上不起作用

将一个类动态添加到 Bootstrap 的popover容器中

模糊事件阻止点击事件工作?

扩展 jQuery 插件的最佳方式

我们如何在不重新加载页面的情况下使用 javascript/jQuery 更新 URL 或查询字符串?

如何在 JQuery DataTable 中默认显示所有行

offsetTop 与 jQuery.offset().top

如何通过 DOM 容器访问 Highcharts 图表?

如何使用 requirejs 使 jQuery 插件可加载

如何在 Bootstrap 中创建切换按钮

如何从所有元素jquery中删除类

通过单击按钮获取表格行的内容

如何使用 jQuery 检测 IE 8?

在 jquery 中使用 AJAX Post 从强类型 MVC3 视图传递模型的正确方法

Ajax 处理中的无效 JSON 原语

$(document).click() 在 iPhone 上无法正常工作. jQuery