简体   繁体   English

如何使用 jQuery 为 IE8 设置背景图像(使用过滤器属性)?

[英]How to set an background-image (using filter attribute) for IE8 using jQuery?

For Chrome and other browsers, we use对于 Chrome 和其他浏览器,我们使用

$('.dummyActive').live("click", function(event){

$('#imageClass').css("background-  image","url(web/M425/images/imgAcc/cards/"+arrayElement[this.id.match(/\d+/)]+") ");

});

Now, since background-size doesnt work with IE8, I am using this CSS,现在,由于背景尺寸不适用于 IE8,我正在使用这个 CSS,

.imageClass{
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='web/M425/images/imgAcc/cards/summyImg.png',sizingMethod='scale')
}

and the above CSS works when i give it using CSS but I do not know how to set an image to a filter using jquery dynamically.当我使用 CSS 给它时,上面的 CSS 有效,但我不知道如何使用 jquery 动态地将图像设置为过滤器。

Now how do i set an image(for IE8) for the above dummyActive live function using javascript or JQuery.现在如何使用 javascript 或 JQuery 为上述 dummyActive 实时功能设置图像(对于 IE8)。

So, i am trying to set filter attribute to dummyActive class(below peice of code) but its not working as i am using both kinds of inverted commas and double inverted commas.所以,我试图将过滤器属性设置为 dummyActive 类(在代码下方),但它不起作用,因为我同时使用了两种引号和双引号。

$('.dummyActive').live("click", function(event){ $('.dummyActive').live("click", function(event){

$('#imageClass').css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='web/M224/images/imgAcc/cards/"+arrayAccountImage[this.id.match(/\d+/)]+"',sizingMethod='scale'+")");

});

For the CSS filter try "-ms-filter" instead of "filter"对于 CSS 过滤器,请尝试“-ms-filter”而不是“filter”

IE8 ignores "filter" CSS styles IE8 忽略“过滤器”CSS 样式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM