Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
How to store color input values into a JavaScript dictionary?

Is trying to find a way to store input color values into a dictionary:

<input type="color" value="#ff0000" id="colorPicker"> 

But the current code can't make any input hex values store into the dictionary even with eventlistener added:

 var Colors = {
    "purple": "FF3CFF",
    "input": ""
 }    

 var colorInput = document.getElementById("colorPicker");
 colorInput.addEventListener("input", function(){
   Colors["input"] = colorInput.value.replace('#','');
 }, false);

The idea of the current code is to store the input color's hex values (removed hash symbol) to the Colors dictionary key input every time the input color changes. But now console.log shown no values can be add to "input"...

Update: apparently the color values can only be recorded inside the addEventLister's function(), so are there anyways to make the values go outside it?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda