Use JQuery’s inArray instead Javascript’s indexOf for cross browser consistency:


inArray: function( elem, array ) {
if ( array.indexOf ) {
return array.indexOf( elem );
}

for ( var i = 0, length = array.length; i < length; i++ ) {
if ( array[ i ] === elem ) {
return i;
}
}

return -1;
}

 

source: http://api.jquery.com/jQuery.inArray/

Advertisements