简体   繁体   中英

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

For Chrome and other browsers, we use

$('.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,

.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.

Now how do i set an image(for IE8) for the above dummyActive live function using javascript or JQuery.

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').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"

IE8 ignores "filter" CSS styles

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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