Reputation: 773
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
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
Reputation: 19465
Maybe its just:
var FilterValue = $('.imgshow-prop-display').css("-ms-filter");
Note the dash >> -ms-filter
Upvotes: 0