effect on attr. ('Javascript style

Asked

Viewed 33 times

0

I need to run this 'Grayscale' filter gradually, which will apply gradually over a period of time.

$('#backstatic').attr('style', 'filter: grayscale(100%)');

this is my line, I wonder if you have how to define the time for the filter effect to apply but gradually.

  • 1

    I’ve seen that you’ve done it but it wouldn’t be better this way? $('#backstatic').css('filter', 'grayscale(100%)'); 'Cause I think that would be wrong

1 answer

1

I resolved so:

$('#backstatic').attr('style', 'filter: grayscale(100%);transition: 2s');

I found that adding the transition style of css3 also works!

then where is 'Transition:' the '2s' is the time.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.