jQuery has one for jQuery objects:

$("div").index( someElement )

> Is there Javascript equivalent of php inArray?

But, no, none exists for a JavaScript Array. However, you can create one easy:

Array.prototype.indexOf = function(obj) {
  for ( var i = 0; i < this.length; i++ )
    if ( this[i] == obj ) return i;
  return -1;
};

and just do something like:

if ( [0,1,2].indexOf(2) >= 0 ) {
   // do stuff
}

--John

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to