change CSS keyframe via jQuery

0

I'm trying to change a keyframe CSS , actually do an update, but I'm not getting concatenar variables CSS to javaScript .

The ideia , in fact, is neither change. But, inserir no final do keyframe lines created

How do I fix this?

       tMin = 0;
       tMax = 20;
       tempoImagens = 20;

       $("@keyframe animacao").css({        

          tMin + "% : margin-left:-" + tempoImagens + "%",
          tMax + "% : margin-left:-" + tempoImagens + "%"   

       });

You are giving concatenation error.

   tMin + "% : 
    
asked by anonymous 25.10.2017 / 12:06

1 answer

0

This is because you are creating a variable and setting its initial value to integer. So when you try to concatenate, the interpreter "thinks" that you are trying to add, then it gives error, like: "HOW TO FINE 20 + 'text'".

Instead of putting this:

tMin = 0;
tMax = 20;
tempoImagens = 20;

Put this:

tMin = "0";
tMax = "20";
tempoImagens = "20";

Or you can also convert the integer value to text before attempting concatenation!

    
31.01.2018 / 14:40