问题描述
当我在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方法不是 jquery.trim 方法.这是您在对象实例上调用的方法(.text()
返回一个字符串).因此,某些浏览器内置了此方法,而IE则没有.
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中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!