Home > Article > Web Front-end > What should I do if the object does not support the indexOf attribute or method?
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!