How to call IE CSS gradient property --> Filter from Jquery

大憨熊 提交于 2019-12-24 09:49:53

问题


I have been trying to call filter css method from jquery for IE, but I am aint b able to do so?

What I using ?

    $('.gtob').mouseover(function(){
        $(this).css("background-image","-moz-linear-gradient(100% 100% 90deg, #373737, #000000)");
        $(this).css("background-image","-webkit-gradient(linear, 0% 0%, 0% 100%, from(#373737), to(#000000))");
        $(this).css("filter","progid:DXImageTransform.Microsoft.gradient( startColorstr='#373737', endColorstr='#000000',GradientType=0)");
    });

The first two lines works great for Firefox, Safari and Chrome but the IE statement give no response :(

So, Anyone know how to do it ?

P:S! I have tried -ms-filter Nothing happens


回答1:


I'd suggest that your code would be much cleaner if you moved those styles to a class in your stylesheet, and then do .addClass() and .removeClass() for your mouseover.

You didn't specify which version of IE you're working with, but for what it's worth, filter is for IE6 and IE7, but IE8 requires -ms-filter. The latter also requires you to escape the quote marks in the filter string.

Finally, you may want to check out CSS3Pie, which is a hack for all versions of IE to allow them to support CSS gradients and border-radius in a slightly more standards-compliant manner.




回答2:


I think gradient has to be capitalized?

  $('.gtob').mouseover(function(){
        $(this).css("background-image","-moz-linear-gradient(100% 100% 90deg, #373737, #000000)");
        $(this).css("background-image","-webkit-gradient(linear, 0% 0%, 0% 100%, from(#373737), to(#000000))");
        $(this).css("filter","progid:DXImageTransform.Microsoft.Gradient( startColorstr='#373737', endColorstr='#000000',GradientType=0)");
    });


来源:https://stackoverflow.com/questions/4413773/how-to-call-ie-css-gradient-property-filter-from-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!