更换亮度滤镜 [英] Changing brightness filter

查看:104
本文介绍了更换亮度滤镜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用jQuery更改页面上某些图像的亮度滤镜css属性,但是在控制台中出现以下错误:解析'滤镜'的值时出错.声明被删除."

I am trying to use jQuery to change the brightness filter css property of some of the images on my page, but I get the following error in the console: "Error in parsing value for 'filter'. Declaration dropped."

这是我正在使用的代码:

Here is the code I am using:

function changeBrightness() {
     $("#myImg").css({
     "filter"         : "brightness(50%)",
     "-webkit-filter" : "brightness(50%)",
     "-moz-filter"    : "brightness(50%)",
     "-o-filter"      : "brightness(50%)",
     "-ms-filter"     : "brightness(50%)"
     });
}

我还尝试了上述格式的其他格式,只是看它是否可以工作,但是它们会产生相同的错误:

I also tried other formats of the above, just to see if it would work, but they produce the same error:

function changeBrightness() {
     var brightness = "brightness(50%)";
     $("#myImg")
        .css("filter",brightness)
        .css("webkitFilter",brightness)
        .css("mozFilter",brightness)
        .css("oFilter",brightness)
        .css("msFilter",brightness);
}

我也尝试了这种通用格式,希望jQuery能够处理前缀:

And I tried this general format as well, hoping jQuery would take care of the prefixes:

function changeBrightness() {
     $("#myImg").css("filter", "brightness(50%)");
}

当我单击按钮时,将调用changeBrightness函数,该函数应将ID为"myImg"的图像的亮度更改为50%.我正在使用Firefox 24.7. CSS3的filter属性是否仅在firefox(或任何其他浏览器)中不起作用?

The changeBrightness function is called when I click a button, and it should change the brightness of an image with the id "myImg" to 50%. I am using Firefox 24.7. Is the filter property for CSS3 just not functional in firefox (or any other browsers)?

推荐答案

CSS3的filter属性是否仅在firefox(或任何其他浏览器)中不起作用?

Is the filter property for CSS3 just not functional in firefox (or any other browsers)?

这是MDN的答案:

这是一项实验性技术

由于该技术的规格不稳定,请检查兼容性表格,以获取在各种浏览器中使用的正确前缀.另外请注意,随着规格的更改,实验技术的语法和行为可能会在将来的浏览器版本中发生变化.

Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

这篇关于更换亮度滤镜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆