Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/05/2014, 22:43
Avatar de berkeleyPunk
berkeleyPunk
 
Fecha de Ingreso: febrero-2013
Ubicación: México :C
Mensajes: 565
Antigüedad: 11 años, 3 meses
Puntos: 22
Pregunta Respuesta: Problema con variables globales!

Cita:
Iniciado por Alexis88 Ver Mensaje
Solo por curiosidad, ¿Ejecutas esa función o la dejas así? Porque probé ejecutándola y funciona bien...

Qué pasó maestro!

Tienes razón maestro, traté de ser tan breve, que me pasé .

Pero el siguiente código no funciona:

Código Javascript:
Ver original
  1. inputA = document.getElementById("inputA"); // Y es indiferente si las declaro o no con "var".
  2.     inputB = document.getElementById("inputB");
  3.  
  4.     function x()
  5.     {
  6.         inputA.style.display = "none";
  7.         inputB.style.color = "red";
  8.     }
  9.     function y()
  10.     {
  11.         inputA.style.visibility = "hidden";
  12.         inputB.style.color = "green";
  13.     }

Código HTML:
Ver original
  1. <a href="#n" onclick="return x()">CLIC 1</a>
  2.     <a href="#n" onclick="return y()">CLIC 2</a>
  3.  
  4.     <input id="inputA" value="HOLA 1" />
  5.     <input id="inputB" value="HOLA 2" />


Última edición por berkeleyPunk; 09/05/2014 a las 22:50