Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!