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

105
Views
Change svg colour with set interval

I am currently working on a project and I want to change the SVG color with time interval...

var bulbColors = [
        '#FFFFFF',
        '#27ae60',
        '#16a085',
        '#f39c12',
        '#e74c3c',
        '#9b59b6',
        '#FB6964',
        '#342224',
        '#472E32',
        '#BDBB99',
        '#77B1A9',
        '#2c3e50'
      ];

   $(function (){
     var i = 0
     $('svg').find('path', this).attr('fill', 'bulbColors[i]')
     setInterval(function(){
       i++;
       if (i == bulbColors.length){
         i = 0;
       }
     $(this).fadeOut('slow', function () {
         $('svg').find('path', this).attr('fill', 'bulbColors[i]')
         $(this).fadeIn("slow");
       })
     }, 6000);
   })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try changing this code

$('svg').find('path', this).attr('fill', 'bulbColors[i]')

You need to unquote bulbColors[i], otherwise javascript reads the argument as a string, and not the hex color in the list at index [i].

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!