IE 7 indexOf() Replacement
Posted: March 11th, 2010 | Author: Rob Searles | Filed under: JavaScript | Tags: jQuery | CommentsEveryday I hate IE a little bit more, and by the same token, everyday I love jQuery that little bit more.
The reason for my hate/love feelings today was due to a bug caused by IE 7 not supporting the indexOf() method. I have no idea why IE doesn’t support this method, but it is annoying never-the-less. However, there is an easy fix if you are using jQuery – the inArray() function.
The inArray() function is pretty simple to use.
Instead of having:
haystack_array.indexOf("needle")
You should use:
jQuery.inArray("needle", haystack_array)
For those of you crazy nutters that aren’t using jQuery, there is a good post on this blog that will help you out.




















