jQuery - 如何调整 CSS 过滤器(模糊)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16781486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 17:45:48  来源:igfitidea点击:

jQuery - How to adjust CSS filter (blur)?

javascriptjquerycss

提问by tehSUPERADMIN

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

对这个运气不太好。我通过 div 上的 CSS 设置了以下内容(我们称之为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 .cssfunction using jQuery. I'd like to set each of them to 0px. Thanks in advance for the help.

我如何通过.css使用 jQuery的函数来调整它。我想将它们每个都设置为 0px。在此先感谢您的帮助。

采纳答案by Doorknob

Try something like this:

尝试这样的事情:

var filterVal = 'blur(0px)';
$('.test')
  .css('filter',filterVal)
  .css('webkitFilter',filterVal)
  .css('mozFilter',filterVal)
  .css('oFilter',filterVal)
  .css('msFilter',filterVal);

回答by Atber

$('.test')
.css({
   'filter'         : 'blur(0px)',
   '-webkit-filter' : 'blur(0px)',
   '-moz-filter'    : 'blur(0px)',
   '-o-filter'      : 'blur(0px)',
   '-ms-filter'     : 'blur(0px)'
});

回答by kraysak

http://jsfiddle.net/mswy6/3/

http://jsfiddle.net/mswy6/3/

                    $("img").css({
                            'filter': 'blur(0px)',
                            '-webkit-filter': 'blur(0px)',
                            '-moz-filter': 'blur(0px)',
                            '-o-filter': 'blur(0px)',
                            '-ms-filter': 'blur(0px)'
                        });