Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - How to adjust CSS filter (blur)?

Haven't had much luck with this one. I have the following set via CSS on a div (let's call it div.test):

filter: blur(2px);
-webkit-filter: blur(2px);
-moz-filter: blur(2px);
-o-filter: blur(2px);
-ms-filter: blur(2px);

How can I adjust this via the .css function using jQuery. I'd like to set each of them to 0px. Thanks in advance for the help.

like image 389
tehSUPERADMIN Avatar asked May 27 '13 22:05

tehSUPERADMIN


People also ask

How to use blur in jQuery?

jQuery blur() Method The blur event occurs when an element loses focus. The blur() method triggers the blur event, or attaches a function to run when a blur event occurs. Tip: This method is often used together with the focus() method.

Can I use filter blur CSS?

The filter CSS property applies graphical effects like blur or color shift to an element. Filters are commonly used to adjust the rendering of images, backgrounds, and borders.

Which CSS property can be used with Blur 10px to blur an image?

Syntax. filter: blur(px); To apply a blur effect to the background image, with the blur function use the z-index property to set the stack order of the element, set the width and height 100% to have a full background image.


2 Answers

$('.test')
.css({
   'filter'         : 'blur(0px)',
   '-webkit-filter' : 'blur(0px)',
   '-moz-filter'    : 'blur(0px)',
   '-o-filter'      : 'blur(0px)',
   '-ms-filter'     : 'blur(0px)'
});
like image 169
Atber Avatar answered Sep 23 '22 21:09

Atber


Try something like this:

var filterVal = 'blur(0px)';
$('.test')
  .css('filter',filterVal)
  .css('webkitFilter',filterVal)
  .css('mozFilter',filterVal)
  .css('oFilter',filterVal)
  .css('msFilter',filterVal);
like image 20
tckmn Avatar answered Sep 21 '22 21:09

tckmn