Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/07/2011, 07:40
Avatar de _cronos2
_cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 10 meses
Puntos: 310
Respuesta: Condicional si determinado DIV contiene a otro

Tomando el ejemplo de @Panino5001, simplemente deberías usar un wrapper y setear el método:
Código Javascript:
Ver original
  1. if(!document.getElementsByClassName){
  2.  document.getElementsByClassName = function(cn){ /* ... */ };
  3. }
  4. var $ = function(obj){
  5.  typeof obj == 'string' && (obj = document.getElementById(obj));
  6.  !obj.contiene && (obj.contiene = function(str){
  7.   if(!obj.getElementsByClassName){
  8.    obj.getElementsByClassName = document.getElementsByClassName;
  9.   }
  10.   return !!obj.getElementsByClassName.call(obj, str).length;
  11.  });
  12. }
  13.  
  14. $('info').contiene('texto'); // true
Para esto, en la función original habría que cambiar document.getElementsByTagName por this.getElementsByTagName.
PD:No he probado el código, supongo que habrá algún fallo
Saludos (:
__________________
" Getting older’s not been on my plans
but it’s never late, it’s never late enough for me to stay. "
Cigarettes - Russian Red