是text.trim()确实无法在IE8中工作 [英] are text.trim() really can't work in IE8

查看:75
本文介绍了是text.trim()确实无法在IE8中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在chrome和firefox中测试我的网页时,它们可以正常工作.但是在IE中无法正常工作.

when i test my web-page in chrome and firefox they work fine. but in IE it does not worked.

我发现

(" .class li").text().trim()在IE中不起作用,他给我一个错误

(" .class li").text().trim() not worked in IE he give me error that

对象不支持此属性或方法.但在FF和chrome中,它们可以正常工作.我在处理这个问题上做错了吗?

Object doesn't support this property or method. but in FF and chrome they work fine. are i goes something wrong to handle this.

推荐答案

尝试一下:

$.trim($(".class li").text());

在您的情况下不起作用的原因是因为您调用的trim方法不是

The reason that it doesn't worked in your case is because the trim method you were calling was wasn't jquery.trim method. It is a method you were calling on a object instance (.text() returns a string). So some browsers have this method built-in while IE doesn't.

这篇关于是text.trim()确实无法在IE8中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆