I am making a program, I want to apply the "Blur" effect when an alert box arrives to the whole document.
Could you suggest me how to do it?
I was using an example I found on the web but I don’t know if it is correct. I am almost sure that the error is in the JavaScript but I don’t know how to correct it.
Thanks for your help.
function addBlur() {
$(‘#main’).addClass(‘blur’);
$(‘#t_TreeNav’).addClass(‘blur’);
}
.body {
heigh: 665px;
background-image: url(https://carontestudio.com/img/caronte-web-estudio-logo.png");
background-size: 10rem;
}
.blur {
flex-grow: 1;
filter: blur(8px);
-webkit-filter: blur(8px);
}
<body>
<h2>This is a sample paragraph.</h2>
</body>
2
Answers
You can accomplish this in vanilla JS with
addEventListener
. You can attach it to DOM like this:You can mix it with jQuery or write it with vanilla JS also:
Probably a better way of doing this would be to use the Dialog element.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog