2

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'+")");

});
deilkalb
  • 355
  • 1
  • 3
  • 9
  • JQuery live() method deprecated since 1.7. so try using .on() method. `$('dummyActive').on('click', function(){ $('#imageClass').css('background-image', 'url(' + imageUrl + ')'); });` – Sachin K May 06 '16 at 12:13
  • @SachinK thanks. But, what is the syntax for setting the above mentioned filter attribute to dummyClass. – deilkalb May 06 '16 at 12:25

1 Answers1

1

For the CSS filter try "-ms-filter" instead of "filter"

IE8 ignores "filter" CSS styles

Community
  • 1
  • 1
meditari
  • 131
  • 2
  • 7
  • IE8 is picking up filter attribute, but now i need to set an image to .imageClass using jQuery as the names of the images can vary. So how do i set the filter attribute to the class in jquery @r00ster – deilkalb May 06 '16 at 12:43
  • Would you not just add the class with jQuery? `$(yourIMageSelector).addClass('imageClass')` [addClass Documentation](https://api.jquery.com/addclass/) – meditari May 06 '16 at 13:08
  • but the image can vary depending upon the selection of various images on the screen. – deilkalb May 06 '16 at 13:23
  • 1
    What is the criteria for the images that need to have the css class set? – meditari May 06 '16 at 13:30
  • There was a syntax error in the code which i mentioned. Thanks for the help @r00ster – deilkalb May 10 '16 at 06:05
  • Glad I could help! @nikhilesh – meditari May 10 '16 at 10:49