escist
escist

Reputation: 773

IE9: Getting the value of 'MS Filter' property using jquery

I am trying to read the value of a CSS property 'MS Filter'. This is my code:

<!--[if IE]> 
<script type="text/javascript">
$(document).ready(function () {
var FilterValue = $(".imgshow-prop-display").css("-ms-filter");
alert("MS- Filter value: " + FilterValue );
});
</script>
<![endif]-->

This is the part of the CSS file which contains definition for the imgshow-prop-display class.

.imgshow-prop-display
{
  background: transparent !important;    
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4D90EE90, endColorstr=#4D90EE90);
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#4D90EE90, endColorstr=#4D90EE90)";    
}

I'm using IE 9 to test this. The alert displays the value "undefined". I have no idea why this is happening. I can read the value of the filter property though.

Upvotes: 2

Views: 719

Answers (2)

underblob
underblob

Reputation: 966

I had to do this for IE8 and had to get the individual properties from the filter:

// Get the non-jQuery native element.
var elem = $('.imgshow-prop-display').get(0);

// Get the properties.
var startColor = elem.filters.item("DXImageTransform.Microsoft.gradient").startColorstr;
var endColor = elem.filters.item("DXImageTransform.Microsoft.gradient").endColorstr;

Upvotes: 1

gideon
gideon

Reputation: 19465

Maybe its just:

var FilterValue = $('.imgshow-prop-display').css("-ms-filter");

Note the dash >> -ms-filter

Upvotes: 0

Related Questions