Good day dear. Faced with a misunderstanding of why JS returns the values of RGB channels, although in CSS I set it under HSL. In general, the problem is such that every two seconds it is necessary to change the color values of the squares. The first and second blocks (columns) of squares should receive +10 to the hue channel every two seconds (That is, after the second second, the classes .first_st * should have the values h = 11 and the classes .second_st * = 21). If the values of h reach 360 then it is added as much as possible and then everything starts from scratch. (That is, at 36 iterations, the classes .first_st * should have the values h = 1 and the classes .second_st * = 11) I'll give the code:
var allFirstColors = $("[class^='first_st']"), firstColorsLength = allFirstColors.length, allSecondColors = $("[class^='second_st']"), secondColorsLength = allFirstColors.length; var h,s,l; console.log(" st1 = " + $(".first_st1").css("fill") ); // Почему возвращает RGB каналы? allFirstColors.each(function(indx, el){ let color = $(el).css("fill"), [h,s,l] = color.match(/\d+/g); console.log("[h,s,l] = " + [h,s,l]); }); .first_st1{ fill: hsl(1, 50%, 50%); } .first_st2{ fill: hsl(1, 70%, 40%); } .first_st3{ fill: hsl(1, 90%, 30%); } .second_st1{ fill: hsl(11, 50%, 50%); } .second_st2{ fill: hsl(11, 70%, 40%); } .second_st3{ fill: hsl(11, 90%, 30%); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <svg width="600" height="240"> <rect class="first_st1" width="80" height="80" x="0" y="0"></rect> <rect class="first_st2" width="80" height="80" x="0" y="80"></rect> <rect class="first_st3" width="80" height="80" x="0" y="160"></rect> <rect class="second_st1" width="80" height="80" x="160" y="0"></rect> <rect class="second_st2" width="80" height="80" x="160" y="80"></rect> <rect class="second_st3" width="80" height="80" x="160" y="160"></rect> </svg>