I use a transparent gradient for a text on my Anki flashcards, styled via CSS like this:
background: -webkit-linear-gradient(-45deg, #cccccc, #ffffff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
Since this is currently for my Anki cards only, I don't need a cross-browser solution yet.
I'd like to change the colors of the gradient with Javascript, but setting the gradient alone via
document.getElementById("ID_of_Text").style.background=
"-webkit-linear-gradient(-45deg, #000000, #ffffff)"
gives me only a gradient in that color, my text and the transparency are removed.
Do I have to set -webkit-background-clip:text
and -webkit-text-fill-color: transparent
again? I've tried to, but this has no effect. Or maybe I did it the wrong way.