Home  >  Article  >  Web Front-end  >  What should I do if the object does not support the indexOf attribute or method?

What should I do if the object does not support the indexOf attribute or method?

小云云
小云云Original
2018-01-10 13:03:273065browse

This article mainly brings you a solution to the problem that the object does not support the indexOf attribute or method (must read). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

var parr = ["a","b","c","d"];

Determine whether a

parr.indexOf(" exists in the parr array a")==-1 Under IE8, it will prompt that the object does not support the indexOf attribute or method

Solution:

Use $.inArray in jquery to replace indexOf

$ .inArray(“a”, parr)==-1

Related recommendations:

Detailed explanation of the difference between js string indexof and search

How to use indexOf() and the difference from jQuery.inArray()

Briefly talk about the indexOf method in JS array

The above is the detailed content of What should I do if the object does not support the indexOf attribute or method?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn