Ver Mensaje Individual
  #26 (permalink)  
Antiguo 04/01/2012, 16:59
Avatar de _cronos2
_cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 11 meses
Puntos: 310
Respuesta: error en internet explorer funcion js

Cita:
Iniciado por IsaBelM
ha de ser que ha sido un día duro y estoy cansada, pero me he quedado uno poco
no es sólo ie, sino también chrome y firefox
Yo me refería a hacer algo así:
Código HTML:
Ver original
  1. <div onclick="miFuncion(this)">abcd</div>
  2. <div id="id"></div>
Código Javascript:
Ver original
  1. var miFuncion = function(e){
  2.  var interesante = e.nextElementSibling || e.nextSibling;
  3.  return interesante.id;
  4. }
Si hablamos de Chrome, FF, etc. o IE9+, existirá la propiedad nextElementSibling y por tanto devolverá el div#id. Si es IE8 o inferior, usará nextSibling porque no existe nextElementSibling, pero en ese caso el nodo de texto vacío no se considerará y por tanto seguirá devolviendo div#id.
Saludos :D
__________________
" 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