【问题标题】:IndexOf in IE8 - how to make it work [duplicate]IE8中的IndexOf - 如何使其工作[重复]
【发布时间】:2014-10-30 05:00:29
【问题描述】:

Internet Explorer 8 中的 indexOf 方法有问题。我在代码中使用它的地方如下所示:

1).

if ( this.allPlays.indexOf(date.getTime()) !== -1 ) {

2).

var others = $footer.text().indexOf('CURRENT') >= 0;

3).

if ( payment.title.indexOf('EURO') >= 0 ) {

4).

that.music.indexOf(calc.getMusic());

如何编写代码,使用什么样的函数? Array.prototype.indexOf 也不能正常工作。

附言。它不是原生 JS,所以我可以使用 jQ 方法。

提前谢谢你:)

【问题讨论】:

标签: javascript jquery arrays internet-explorer-8 prototype


【解决方案1】:

jQuery 为数组提供inArray,因此您可以避免使用 indexOf 的数组版本(IE8 中不存在)。

您的其他两个示例正在使用 IE8 中确实存在的 indexOf 的字符串版本。

【讨论】:

    猜你喜欢
    • 2013-04-17
    • 2016-03-10
    • 2014-05-19
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    相关资源
    最近更新 更多