开发者

Setting opacity with jquery not working in IE8, but works in IE7

开发者 https://www.devze.com 2023-01-29 14:52 出处:网络
My code: $(\'.diff a\').css(\'opacity\', .5); Works in IE7, firefox, and chrome, correctly making the开发者_如何学Python anchor elements appear faded, but not in IE8.

My code:

$('.diff a').css('opacity', .5);

Works in IE7, firefox, and chrome, correctly making the开发者_如何学Python anchor elements appear faded, but not in IE8.

I'm using jquery 1.4.4

EDIT: Here is a test page showing problem http://jsfiddle.net/KUJYF/


Why are you using opacity at all? Why not just use a lighter color to simulate the effect and not have the overhead the opacity property introduces.


I ran across this same situation while trying to animate opacity for fading in and out a span element. Under IE7, animating the span worked flawlessly. Under IE9, same story. But, under IE8, there was no animation.

Thanks to the comments to the original question posed above, I found that by setting the CSS style of the span to inline-block, animation started working in IE8, which leads me to believe that IE8 may not support opacity on inline elements (at least, not the way that jQuery 1.4.4 implemented it).

Here's the sample I used for testing: http://jsfiddle.net/ddYuJ/2/


Use fadeto

http://api.jquery.com/fadeTo/

0

精彩评论

暂无评论...
验证码 换一张
取 消