I am trying something like this:
let str = 10;
let blu = "px";
let val = "";
function check() {
if(a < b){
str = str - 6;
if (str<0){str = 0}
val = str+blu;
document.getElementById("img1").`style.filter = 'blur(val)';
}
Here the value of ‘str’ and hence ‘val’ changes everytime the function ‘check’ is run, but ‘blur(val)’ gives an error.
I was expecting that a variable can be used here. I also tried setProperty.
document.getElementById("img1").style.setProperty("blur", val);
but this also gives error.
What is the solution?
Also, how do you reduce the blur of a text or a image according to a timer. For example, if the initial blur is set to 60px, every passing second, the blur reduces by 1 px, and finally after 1 minute, entire text is clearly visible?
2
Answers
Here is one where I guessed at what you wanted with a and b
Yes, but why not use a CSS transition instead? Simple and smooth.