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

191
Views
Cant store rgba Values with local storage JS

Cant store rgba Values with local storage. Either that or I have made a mistake. Were dealing with a few things here.

In my Js file I have stored a color picker RGBA value as a string and stored it as seen below.

pickr.on('change', (color, source, instance) => {
    
  const rgbaColor = color.toRGBA().toString();
  console.log(rgbaColor)
  localStorage.setItem("C1",rgbaColor);
 
})

Then I have a separate Js file with this function.

function colors(){
  document.querySelector('teamOne').style.background = localStorage.getItem("C1");
} 

And Im trying to change the background color of a div in my css file. (im using scss btw)

#teamOne {
  width: 50%;  
}

I know that the color picker is working but the rest of the code wont. If someone could help that would be great.

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Figured it out. Should be:

document.getElementById('teamOne').style.backgroundColor = localStorage.getItem('C1');

about 4 years ago · Juan Pablo Isaza Report
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!