Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/11/2010, 15:07
PabloLPastor
 
Fecha de Ingreso: junio-2009
Ubicación: Madrid
Mensajes: 46
Antigüedad: 14 años, 11 meses
Puntos: 7
Respuesta: Como detectar un elemento en un Array?

JavaScript no tiene una función para eso, te la tienes que hacer tú, algo como esto:


Código Javascript:
Ver original
  1. function enArray (miArray, elemento) {
  2.  
  3.    for ( var i = 0; i < miArray.length; i++ ) {
  4.       if ( miArray[i] === elemento ) return true;
  5.       return false;
  6.   }
  7.  
  8. }
__________________
Quizá te interese mi Tutorial de JavaScript Orientado a Objetos.

Nuevo: CSS Floats: Tutorial Visual